'MaterialButton onPressed listener not work (Flutter)
I created a layout like this, the problem is that the onPressed listener doesn't work but I can't understand why:
Material(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(22.0)),
color: const Color.fromRGBO(33, 63, 132, 1),
clipBehavior: Clip.antiAlias,
child: MaterialButton(
height: 140.0,
minWidth: 380.0,
elevation: 20.0,
color: const Color.fromRGBO(33, 63, 132, 1),
textColor: Colors.white,
child: Text("Chiudi sessione / Cambia utente",
style: TextStyle(
fontSize: ScreenUtil().setSp(20),
)),
onPressed: () {
var future = endUserSession(badgeCode, false, context);
future.then((value) {
setUserBadgeForDualMode("");
setDoorStatusIntoPrefs("");
Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => const OpenDoorDualMode()));
});
}
),
)
What am I doing wrong?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
