Reputation: 852
Here is my code
final _months = [
["January", "Febuary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
];
......
DropdownButtonFormField(
hint: const Text('Select Period'),
items: _months.map((e) {
return DropdownMenuItem(
value: e,
child: Text(e //here is the error showing),
);
}).toList(),
onChanged: (value) {
//do something
},
),
How to solve this , i just changed the months map value to dynamic from dfault, then the error is gone, but when i run the app it showing the another error like "this is not subtype of string" how to fix this and why is this happening
Upvotes: 0
Views: 132
Reputation: 2425
you have array inside array : correct is :
final _months = [
"January", "Febuary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
];
Upvotes: 0
Reputation: 4656
You have an extra set of [ ]
so your _months
variable is of type List<List<String>>
:
final _months = ["January", "Febuary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
Upvotes: 2