fix(修复DialogDemo, 无法关闭的问题):

This commit is contained in:
sanfan.hx
2019-01-13 12:43:41 +08:00
parent fbbd1f6731
commit 0b1cff580e

View File

@ -22,7 +22,21 @@ class _Demo extends State<DialogDemo> {
barrierDismissible: false, // user must tap button! barrierDismissible: false, // user must tap button!
builder: (BuildContext context) { builder: (BuildContext context) {
return Dialog( return Dialog(
child: Text("我是一个Dialog"), child: Container(
height: 100,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Text('我是一个dialog'),
RaisedButton(
child: Text('取消'),
onPressed: () {
Navigator.of(context).pop();
},
)
],
),
)
); );
}, },
); );
@ -63,15 +77,30 @@ class _DialogMoreDemo extends State<DialogMoreDemo> {
return StatefulBuilder( return StatefulBuilder(
builder: (context, state) { builder: (context, state) {
return Dialog( return Dialog(
child: RaisedButton( child: Container(
height: 150,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Text('我是一个dialog'),
RaisedButton(
onPressed: () { onPressed: () {
print("print $value");
state(() { state(() {
value += 1; value += 1;
}); });
}, },
child: Text("我是一个Dialog, 点我更新value: $value"), child: Text("我是一个Dialog, 点我更新value: $value"),
),
RaisedButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text("取消"),
) )
],
),
),
); );
} }
); );