skip to Main Content

using Stream I get the data from firebase

void getsds() async {
DatabaseReference ref =
    FirebaseDatabase.instance.ref("NearbyAccidents/User1/acc_coordinates");



Stream<DatabaseEvent> stream = ref.onValue;



stream.listen((DatabaseEvent event) {
  print('Event Type: ${event.type}'); // DatabaseEventType.value;

  print('Snapshot: ${event.snapshot.value}');

  List<Object?> map1 = event.snapshot.value as dynamic;

  print(map1[0]);

});

}

enter image description here

for printing map[0] I got this. but this is object. so I want to convert as map

How can covert this object to map

2

Answers


  1. Chosen as BEST ANSWER
    final mapCreated = Map.from(map1[0] as Map<Object?, Object?>);
    

  2. Try this it will solve your problem

    final mapCreated = Map.from(map1[0]);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search