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

type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'String' with AlphabetScrollView

I want to implement https://pub.dev/packages/alphabet_scroll_view in my project.

I receive data from backend and I parse it to list, but when I want to give it to above package as list I am getting this error:
type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'String'

This how my list is looking after parsing it:

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

[
{
 id: 1222,
 hidden: 1,
 nick_name: Saraya,
 id_fb: ,
 avatar: api/images/user/d4bfsd8769147.png,
 city: Toruń, Polska
}, 
{
 id: 2029,
 hidden: 1,
 etc.
}

and here is how I set it in my project:

AlphabetScrollView(
     list: (snapshot.data! as List).map((e) => AlphaModel(e)).toList(),
     selectedTextStyle: TextStyle(),
     unselectedTextStyle: TextStyle(),

I am not good with these Lists and Maps and I don’t have idea what I need to change to get rid of this error.

>Solution :

The constructor of AlphaModel expects a String but you are giving it a Map. Assuming you want to sort by nickname you can maybe do this instead:

 list: (snapshot.data! as List).map((e) => AlphaModel(e['nick_name']).toList(),
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