Hi what my goal is to display enum values inside of a dropdown menu and to replace setState with ValueNotifier and ValueListenableBuilder. I'm fairly new to flutter and currently I only know how to display dropdown menu when we have a list of strings and its using setState but how can I modify it. So for instance we have enum Locations={belgium,germany,spain, etc}
This is my code so far:
class _TestState extends State<Test> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('hi'),
),
drawer: FoodNotifyDrawer('name'),
body: Container(
padding: EdgeInsets.all(7),
child: Center(
child: Column(
children: [
SizedBox(
height: 40,
),
DropdownButton(
// Not necessary for Option 1
value: _selectedLocation,
onChanged: (String? newValue) {
setState(() {
_selectedLocation = newValue;
});
},
items: _locations.map((location) {
return DropdownMenuItem(
child: Text(location),
value: location,
);
}).toList(),
),
SizedBox(
height: 40,
),
Text('Option 2'),
SizedBox(
height: 40,
),
],
),
),
),
);
}
}
Any help would be great, thanks in advance :)
