Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to solve "The argument type 'List<String>' can't be assigned to the parameter type 'String"

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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"];
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading