I'm new with Flutter. I want to display DropdownMenuItem from my list variable. Check out my code.
// my list variable
List listUserType = [
{'name': 'Individual', 'value': 'individual'},
{'name': 'Company', 'value': 'company'}
];
// items property in DropdownMenuItem
return DropdownButtonFormField<List<Map>>(
decoration: InputDecoration(
prefixIcon: Icon(Icons.settings),
hintText: 'Organisation Type',
filled: true,
fillColor: Colors.white,
errorStyle: TextStyle(color: Colors.yellow),
),
items: listUserType.map((map) {
return DropdownMenuItem(
child: Text(map['name']),
value: map['value'],
);
}).toList());
This is the result I got
I/flutter (22528): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (22528): The following assertion was thrown building RegisterPage(dirty, state: RegisterPageState#5b83a):
I/flutter (22528): type 'List<DropdownMenuItem<dynamic>>' is not a subtype of type
I/flutter (22528): 'List<DropdownMenuItem<List<Map<dynamic, dynamic>>>>'
I do not know what is causing the error.