Whenever I used FlatButton onPressed Method Is Not Working In Positioned Widget.
I am designing one screen in that buttons are always in the bottom of the screen and that button click we can move to other screens,but here it is not working, can anyone check and help me out.thaks in advance
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,
),
),
),
),
],
)),
Change this line:
MaterialPageRoute(builder: (context) => MainScreen());
to this:
Navigator.push(context, MaterialPageRoute(builder: (context) => MainScreen()));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With