How to update the Homepage just after the showDialog()
is dismissed/disposed? Doesn\'t seem like it has an onDispose()
function.
Found another
It really depends on the type of updates you want to have.
However, this is a simple example that may help you figure it out.
class Home extends StatefulWidget {
@override
_HomeState createState() => new _HomeState();
}
class _HomeState extends State {
String _homeData = "initial data";
@override
Widget build(BuildContext context) {
return new Scaffold(
body: new Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
new Text(_homeData),
new RaisedButton(
child: new Text("Show Dialog"),
onPressed: ()async{
bool shouldUpdate = await showDialog(
context: this.context,
child:new AlertDialog(
content: new FlatButton(
child: new Text("update home"),
onPressed: () => Navigator.pop(context, true),
),
),
);
setState(() {
shouldUpdate ? this._homeData = "updated" : null;
});
},
),
],
),
),
);
}
}