I\' m gettings items from JSON and displaying them in a dropdown. When the person select an item from the dropdown list, I get the selection but the selected item doesn\'t c
This is the solution: "StatefulBuilder()"
Future AgregarContacto() async {
String dropdownValue = 'Exento';
return showDialog(
context: context,
barrierDismissible: true, // user must tap button!
builder: (BuildContext context) {
return StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return AlertDialog(
title: Text('Agregar cliente', textAlign: TextAlign.center,),
content:
SingleChildScrollView(
child: ListBody(
children: [
Center(
child: Material(
type: MaterialType.transparency,
child: DropdownButton(
items: [
'Responsable inscripto',
'Monotributista',
'Exento',
'Consumidor final',
'No responsable'
]
.map>((
String value) {
return DropdownMenuItem(
value: value,
child: Text(value),
); //DropMenuItem
}).toList(),
value: dropdownValue,
onChanged: (String newValue) {
setState(() {
dropdownValue = newValue;
print("new${newValue}");
}); //setState
},
//OnChange
isExpanded: false,
hint: Text('Responsable inscripto',
style: TextStyle(color: Colors.black),),
),
), //Material
), //Center
],
),
),
actions: [
FlatButton(
child: Text('Regret'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
}
);
},
);
}