I'm making sign in system in flutter.
I want to use alertDialog for sign in failed.
if-else is included in onpressed:
else {
AlertDialog(
title: Column(
children: <Widget>[
new Text("Log in failed"),
],
),
//
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"ID or Password doesn't exist",
),
],
),
actions: <Widget>[
new FlatButton(
child: new Text("OK"),
onPressed: () {
Navigator.pop(context);
},
),
],
);
Writing return doesn't work and deleting return doesn't show anything.
How to fix this?
You need to call showDialog
and pass the AlertDialog
you created.
The demo I created on DartPad .
await showDialog(
context: context,
builder: (context) => AlertDialog(
title: Column(
children: <Widget>[
new Text("Log in failed"),
],
),
//
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"ID or Password doesn't exist",
),
],
),
actions: <Widget>[
new FlatButton(
child: new Text("OK"),
onPressed: () {
Navigator.pop(context);
},
),
],
),
);
Note: Use TextButton instead of FlatButton because FlatButton is deprecated .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.