Пользователь StatefulBuilder
для возврата AlertDialog
.
showDialog(
context: context,
builder: (context) {
String contentText = "Initial Content";
return StatefulBuilder(
builder: (context, setState) {
return AlertDialog(
title: Text("Title Here"),
content: Text(contentText),
actions: <Widget>[
FlatButton(
onPressed: () => Navigator.pop(context),
child: Text("Cancel"),
),
FlatButton(
onPressed: () {
setState(() {
contentText = "Changed!";
});
},
child: Text("Change Now"),
),
],
);
},
);
},
);