DropdownButton value is not updating after selecting values from DropdownItems. How to update default value with _selectedLocation?
The variables i use:
String? stateToCountry;
List? stateID;
List? cityJson;
Position? _position;
String? currentAddress;
Placemark? place;
DropdownButton(
hint:_selectedLocation==null ? Text('Dropdown') : Text(
_selectedLocation.toString(),
style: TextStyle(color: Colors.black),
),
isExpanded: true,
iconSize: 30,
elevation: 16,
underline: Container(
height: 2,
color: Colors.deepPurpleAccent,
),
style: TextStyle(color: Colors.deepPurple, fontSize: 20.0),
itemHeight: 50,
items: countrylist!.map((location){
return DropdownMenuItem(
value: location,
child: new Text(location["name"].toString()),
);
}).toList(),
onChanged: (newValue){
setState(() {
_selectedLocation=newValue as String?;
});
},
),