close

[Solved] Error: List is not a subtype of type Map

Hello Guys How are you all? Hope You all are fine. When I was trying to run my flutter app and suddenly I get the following error in my stack track. Error: List is not a subtype of type Map in a flutter. So today Here I come with all possible solutions for this error.

We are providing you all possible solutions to solve this error. let’s start this article without wasting your time.

How Error: List dynamic is not a subtype of type Map String, dynamic Occurs ?

I have List of json String Then I convert Json String to json list and I am trying to assing json list to List variable But got following error.

How to Solve Error: List dynamic is not a subtype of type Map String, dynamic?

Question: How to Solve Error: List dynamic is not a subtype of type Map String, dynamic?
Answer: Error: List is not a subtype of type Map this means the data which you are receiving after hitting a web service is in form of a List but inside the data class which you have used is of type Map. So, it is not able to parse the data due to structure mismatch as Map is defined in instead of List in data class.

Solution 1: Use List.from

Just look This example to solve your error.

Now you can use userData as List. So all you need to do is just add your json list into List.from();

Solution 2: Recheck your Json response and corresponding PODO class

basically, this error means the data which you are receiving after hitting a web service is in form of a List but inside the data class which you have used is of type Map. So, it is not able to parse the data due to structure mismatch as Map is defined in instead of List in data class.

Summery

So, It’s All About This Error. I hope this tutorial helps you to Solve your error. Please Comment Below if You stucks anywhere with my code. And please comment below on which solution worked for you. Thank You.

Also Check Out Below Tutorials

Leave a Comment

%d bloggers like this: