I have a 2d dynamic list which is being read from a json file and want to convert it into a 2d string list.
CurrentPuzzle({
List<List<String>> letterMat = const [],
}) : _letterMat = letterMat;
factory CurrentPuzzle.fromJSON(dynamic jsonData) {
return CurrentPuzzle(
letterMat: List<List<String>>.from(jsonData['current_puzzle']['_letterMat']),
);
Data is being read from a json file
{
"current_puzzle": {
"_letterMat": [
["z", "b", "a"],
["c", "d", "e"],
["f", "g", "h"],
["i", "j", "k"]
]
}
}
I have tried using
List<List<String>>.from(jsonData['current_puzzle']['_letterMat'])
but run into an error of:
Exception has occurred.
_TypeError (type 'List<dynamic>' is not a subtype of type 'List<String>')
Anysort of help is appreciated!