Home > Mobile >  how can i get the value of a child in firebase database realtime in flutter?
how can i get the value of a child in firebase database realtime in flutter?

Time:02-21

I would like to be able to obtain the data that is inside "grupofav", this data is equivalent to "grupoid3", but I cannot access the reference that is equivalent to that value in firebase datebase realtime, the idea is to be able to pass the id of the favorite group to another reference accessing that particular group.

i tried doing this

var grupoFav = FirebaseDatabase.instance
  .ref()
  .child("usuarios")
  .child("T1gMWDq6d6R6cKSyd8StjKV8drg1")
  .child("grupofav")
  .get()
  .toString();

but with get, onvalue and others, I couldn't get to the data

image refence

CodePudding user response:

get is an asynchronous operation, so you'll need to await its result:

var dbRef = FirebaseDatabase.instance
  .ref()
  .child("usuarios")
  .child("T1gMWDq6d6R6cKSyd8StjKV8drg1")
  .child("grupofav")
var snapshot = await dbRef.get(); //            
  • Related