fultter Firebase Realtimebase question. Unhandled Exception: type '_InternalLinkedHashMap<Object?, Object?>' is not a subtype of type 'String'

Viewed 16

my json file is like this. enter image description here

I want to use it in flutter. json file loaded from firebase. my code is like this

enter image description here

and I made model.dart

enter image description here

This error message appears on the console.

Unhandled Exception: type '_InternalLinkedHashMap<Object?, Object?>' is not a subtype of type 'String'

How should I create the code? Help. I am a beginner T_T thank U.

2 Answers

The error message tells you, that some function expected a String, but received a HashMap instead.

In this case, jsonDecode is the cause. From the documentation you can see that it requires a String as a first argument.

But event.snapshot.value seems to be a HashMap already instead of a string. So you don't need to call jsonDecode on it. Take this documentation as an example

comment the print methods that locate in the function and retry

Related