Hi I have a drop down menu and a date selector in an alert dialog. The selections print on the console onChange so I know that it's working but they won't change in the actual alert dialog unless I close and reopen it again. Is there any way I can get the date and drop down menu selections to change in realtime??
My drop down code is as follows :
void rightButtonPressed() {
setState(() {
walkDuration = dependencies.stopwatch.elapsedMilliseconds~/60000;
if (dependencies.stopwatch.isRunning) {
dependencies.stopwatch.stop();
showDialog(
context: context,
builder: (BuildContext context){
return AlertDialog(
actions: <Widget>[
Theme(
child: Button(
child: const Text('Add'),
onPressed: (){
add();
Navigator.of(context).pop();
},
style: Style(
color: Colors.white,
)
),
)
],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8)),
content: Stack(
overflow: Overflow.visible,
children: <Widget>[
Form(
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Padding(
padding: EdgeInsets.all(5.0),
child: Column(
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
DropdownButton(
value: numberTimes,
items: [
DropdownMenuItem(
child: Text("0", style: TextStyle(fontSize:15.0)),
value: 0,
),
DropdownMenuItem(
child: Text("1", style: TextStyle(fontSize:15.0)),
value: 1,
),
DropdownMenuItem(
child: Text("2", style: TextStyle(fontSize:15.0)),
value: 2,
),
DropdownMenuItem(
child: Text("3", style: TextStyle(fontSize:15.0)),
value: 3,
),
DropdownMenuItem(
child: Text("4", style: TextStyle(fontSize:15.0)),
value: 4,
),
DropdownMenuItem(
child: Text("5", style: TextStyle(fontSize:15.0)),
value: 5,
),
DropdownMenuItem(
child: Text("5+", style: TextStyle(fontSize:15.0)),
value: 6,
),
],
onChanged:(value) {
setState((){
numberTimes = value;
print(numberTimes);
});
}
),
],
)
),