I am getting data from SQLite in flutter. When I try to convert the list of Map to list of Objects. It gives the error of
The method 'add' was called on null
On debuging, it shows that it has data but still gives the error.
Here is my code
List<Image> imagesList;
if (imagesListMap != null) {
imagesListMap.forEach((element) {
imagesList.add(Image.FromDatabase(element));
});
}
And its the debugging screenshot
You need to initialize the
List
like this before callingadd()
on it..