Home > other >  Flutter type 'List<String>' is not a subtype of type 'String'
Flutter type 'List<String>' is not a subtype of type 'String'

Time:01-29

I am making my flutter firebase app and in it I'm fetching image from list but its giving me this error type 'List<String>' is not a subtype of type 'String' on this line in my listTile

 leading: Image.network(
                          _provider.dataToFirestore['images'][0]),

Now if I do convert it into string by adding .toString like this

 leading: Image.network(_provider.dataToFirestore['images']
                              [0]
                          .toString()),

my screen comes back and works but doesn't shows the image cause it's network type not string so how can I resolve this issue.

This is where I'm storing my image

List<String> urlList = [];
Map<String, dynamic> dataToFirestore = {};

If anyone understand where I'm making issue please help, thanks

CodePudding user response:

What this message mean is _provider.dataToFirestore['images'][0]) this returning a List of String not actually a String. You may know List<String> and String are not the same type of data.What I assume in your case _provider.dataToFirestore['images'][0][0]) will return a String from the List of String

  •  Tags:  
  • Related