我创建了这样的布局,问题是 onPressed 侦听器不起作用,但我不明白为什么:
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()));
});
}
),
)
我究竟做错了什么?