'how can i get the value of a child in firebase database realtime in flutter?

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 database real-time, the idea is to be able to pass the id of the favourite 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



Solution 1:[1]

try following

FirebaseDatabase.instance
  .ref()
  .child("usuarios")
  .orderByChild('groupfav')
  .get();
  

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1