When i creat a realtime database table then i get the table datas but i got an error: type ‘String’ is not a subtype of type ‘Map<dynamic, dynamic>’ in type cast
FirebaseAnimatedList(
query: dbRef,
itemBuilder: (BuildContext context, DataSnapshot snapshot,
Animation<double> animation, int index) {
Map data = snapshot.value as Map;
data['key'] = snapshot.key;
return listItem(data);
},
),
I got Result
3
Answers
Here snapshot.data is a map and snapshot.value is string
Try
You need to convert the dynamic value which comes in string into decoded jsonMap if it is a map using
jsonDecode
. Or, you can use snapshot.data which comes in terms of key, value pair Map.I think your query returning single value,
First test with it
Now for getting map, it is possible to get null value, for this case do