Reputation: 341
I have a 2d-List with a String and a Map inside like this:
List<List<dynamic>> content =
[
[
"String",
{
"one": 23,
"two: "two"
}
],
];
To store this as a string locally I use json.encode(content).
But when I want to use
json.decode("[["String",{"one": 23,"two: "two"}],]")
to make this a variable of the type List<List<dynamic>
I get the error:
type 'List<dynamic>' is not a subtype of type 'List<List<dynamic>>'
How do I solve this? Thanks for the help!
Upvotes: 1
Views: 84
Reputation: 341
I solved it myself. I don't really understand why but this works.
content = List.from(json.decode("[["String",{"one": 23,"two: "two"}],]"));
Upvotes: 0
Reputation: 406
You need to put List</*here*/>
an object what type the List should be. Your list should look like this: List<List<Dynamic>>
. Class name instead of it's instance.
Upvotes: 1