I have a DataSnapshot JSON object :
{fridge2: true, fridge1: true} //data pulled from a real time firebase database
I have to put fri
I solved it. I used to print(fridgesDs.runtimeType);
to get the type of variable returned by firebase. it is actually a HashMap: _InternalLinkedHashMap<dynamic, dynamic>
The casted the returned value into a Map. Finally, I used forEach to loop through the map. Here is the final version:
Map<dynamic, dynamic> fridgesDs = snapshot.value['fridges'];
// print(fridgesDs.runtimeType);
fridgesDs.forEach((key, value) {
if (value) {
fridges.add(key);
}
});
you insert just the key and you have to insert key and values i think or tell me what is ur list ..ArrayList , stack,Linked List or tree i think all what you need to do .. fridges.add(fridge.key,fridge.value);