gpt4 book ai didi

flutter - FlatButton onPressed 在定位小部件中不起作用

转载 作者:行者123 更新时间:2023-12-03 02:48:13 25 4
gpt4 key购买 nike

每当我在 Positioned Widget 中使用 FlatButton onPressed 方法时都不起作用。

我正在设计一个屏幕,按钮总是在屏幕底部,单击该按钮我们可以移动到其他屏幕,但这里不起作用,任何人都可以检查并帮助我。提前谢谢

           child: Stack(
// height: MediaQuery.of(context).size.height,
children: <Widget>[
Positioned(
left: 0,
bottom: 0,
// alignment: Alignment(0, 0),
child: Row(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
SizedBox(height: 115),
ButtonTheme(
minWidth:
MediaQuery.of(context).size.width / 2,
height: 60.0,
child: FlatButton.icon(
icon: Icon(FontAwesomeIcons.fileInvoice),
color: Colors.white,
onPressed: () {
MaterialPageRoute(builder: (context) => MainScreen());
},
label: Text(
"My Orders",
textAlign: TextAlign.center,
style: TextStyle(
// decoration: TextDecoration.underline,
fontSize: 25,
fontWeight: FontWeight.bold,
color: Theme.of(context).accentColor,
),
),
),
),
SizedBox(height: 115),
ButtonTheme(
minWidth:
MediaQuery.of(context).size.width / 2,
height: 60.0,
child: FlatButton.icon(
icon: Icon(FontAwesomeIcons.dollarSign),
color: Colors.white60,
onPressed: () {
Navigator.pushReplacementNamed(
context, '/home');
},
label: Text(
"Bean Balnace",
textAlign: TextAlign.center,
style: TextStyle(
// decoration: TextDecoration.underline,
fontWeight: FontWeight.bold,
fontSize: 20,
color: Theme.of(context).accentColor,
),
),
),
),
],
)),

最佳答案

改变这一行:

MaterialPageRoute(builder: (context) => MainScreen());

为此:

Navigator.push(context, MaterialPageRoute(builder: (context) => MainScreen()));

关于flutter - FlatButton onPressed 在定位小部件中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57918860/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com