When I added the 'value' parameter to the DropdownButton my app crashed with the exception I mentioned in the title. When I'm removing the 'value' parameter it workd but showing a hint and when I select a value from the list its not really selecten I mean I can't see I selected it
Widget build(BuildContext context) {
String dropdownValue = 'Categories';
return Scaffold(
appBar: AppBar(
title: Text(
'Podium',
style: TextStyle(fontSize: 18),
),
backgroundColor: Colors.black54,
),
backgroundColor: Colors.grey,
body: FutureBuilder<Competition>(
future: widget.jsonData.fetchComp(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return Center(
child: Column(
children: <Widget>[
Text(
snapshot.data.compName,
style: TextStyle(fontSize: 18),
),
DropdownButton<String>(
items:
snapshot.data.categoriesNames.map((dropdownStringItem) {
return DropdownMenuItem<String>(
value: dropdownStringItem,
child: Text(dropdownStringItem),
);
}).toList(),
onChanged: (newItemSelected) {
setState(() {
dropdownValue = newItemSelected;
});
},
value: dropdownValue,
elevation: 16,
icon: Icon(Icons.arrow_downward),
iconSize: 24,
style: TextStyle(color: Colors.black54),
underline: Container(
height: 2,
color: Colors.deepPurpleAccent,
),
)
],
));
} else if (snapshot.hasError) {
return Text('${snapshot.error}');
}
return Center(
child: CircularProgressIndicator(),
);
},
));
}