close

[Solved] type ‘List‘ is not a subtype of type ‘List‘ Flutter

Hello Guys, how are you all? Hope you all are fine. You might face type ‘List<dynamic>’ is not a subtype of type ‘List<int>’ Flutter as this error in a flutter. 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 type ‘List<dynamic>’ is not a subtype of type ‘List<int>’ Flutter Error Occurs ?

I am trying to run my code but o found this error in my stacktrack

‘List<dynamic>’ is not a subtype of type ‘List<int>’

At this below line. Here Is I Am Facing Above Error.

Solutions

Question : How to Solve type ‘List<dynamic>’ is not a subtyoe of type ‘List<int>’ ?
Answer : You need to bring the value to its required type before you can assign it. So, all you need to do is Just cast your variable to Integer.

Solution 1

types in JSON maps or lists don’t have concrete generic types. generateID requires a List<int> not a List (or List<dynamic>), therefore you need to bring the value to its required type before you can assign it. So That just follow below step.

Change

to

This Solution Worked for me.

Solution 2

A shorten way to handle is

Solution 3

We could also initializing new List instead of casting. same as below.

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

Milan Dhameliya is an Information Technology Engineer. By profession, he is a Full Stack developer with knowledge of multiple back-end platforms (e.g., PHP, Node.js, Python) and frontend Flutter frameworks.

Leave a Comment