mirror of
https://github.com/tonytins/bullseye.git
synced 2025-04-30 10:21:39 -04:00
Show alert dialog
This commit is contained in:
parent
22cecb89a4
commit
90dafce466
1 changed files with 29 additions and 1 deletions
|
@ -25,6 +25,8 @@ class GamePage extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _GamePageState extends State<GamePage> {
|
class _GamePageState extends State<GamePage> {
|
||||||
|
bool _alertIsVisable = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
@ -35,10 +37,36 @@ class _GamePageState extends State<GamePage> {
|
||||||
Text("Hello World!",
|
Text("Hello World!",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold, color: Colors.green)),
|
fontWeight: FontWeight.bold, color: Colors.green)),
|
||||||
TextButton(child: Text('Hit me!'), onPressed: () {})
|
TextButton(
|
||||||
|
child: Text('Hit me!'),
|
||||||
|
onPressed: () {
|
||||||
|
this._alertIsVisable = true;
|
||||||
|
_showAlert(context);
|
||||||
|
})
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _showAlert(BuildContext context) {
|
||||||
|
Widget okButton = TextButton(
|
||||||
|
child: Text("Awesome!"),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
this._alertIsVisable = false;
|
||||||
|
print("Awesome Pressed! $_alertIsVisable");
|
||||||
|
});
|
||||||
|
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: Text("Hello There."),
|
||||||
|
content: Text("This is my first pop-up."),
|
||||||
|
actions: <Widget>[okButton],
|
||||||
|
elevation: 5,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue