close

[Solved] Unhandled Exception: InternalLinkedHashMap‘ is not a subtype of type ‘List

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 mine stack track. Unhandled Exception: InternalLinkedHashMap’ is not a subtype of type ‘List<dynamic> in 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 Unhandled Exception: InternalLinkedHashMap’ is not a subtype of type ‘List<dynamic> Error occurs ?

When I was trying to run my flutter app and suddenly I get the following error in mine stack track. I am trying to get the JSON response from the server and output it to the console.

Unhandled Exception: type ‘_InternalLinkedHashMap<String, dynamic>’ is not a subtype of type ‘List

Here Is Line where I am facing this error.

var userdata;
userdata = json.decode(response['body']); //response['body'] is API response

Solutions

Question: How to solve Unhandled Exception: InternalLinkedHashMap’ is not a subtype of type ‘List<dynamic> ?
Answer:
You have to convert the runtimeType of data from _InternalLinkedHashMap to an actual List. One way is to use the List.from.

Solution 1

You have to convert the runtimeType of data from _InternalLinkedHashMap to an actual List. One way is to use the List.from.

final userdata = List<dynamic>.from(
  data.map<dynamic>(
    (dynamic item) => response['body'],
  ),
);

Solution 2

You can use

final userdata = new Map<String, dynamic>.from(response['body']);

Solution 3

This Solution also worked.

Map<String, dynamic> userdata = new Map<String, dynamic>.from(json.decode(response['body']));

Solution 4

You have to convert the runtimeType of data from _InternalLinkedHashMap to an actual List.

One way is to use the List.from.

final userdata = List<dynamic>.from(
  data.map<dynamic>(
    (dynamic item) => response.body,
  ),
);

Solution 5

  1. Create a List Data
  2. Use Map to decode the JSON file
  3. Use the List object Data to fetch the name of the JSON files
  4. With the help of index and the list object I have printed the items dynamically from the JSON file
Map<String, dynamic> userdata = json.decode(response.body);

Solution 6

This Solution Also Worked For Me.

Map<String, dynamic> myMap = new Map<String, dynamic>.from(response['body']);

userdata = myMap;

Summery

So it’s all About All possible solutions. Hope this above all solution helped you a lot. Comment below Your thoughts and your queries. Comment Below on your suggestion.

Check Out Below Article

Leave a Comment

%d bloggers like this: