I am struggling to reference specific things in my firebase real time database. I understand that when you want to read something specific from the database you need to specify the exact path where the item can be found.
If you see the screenshot attached, I want a way to read the name of each menuItem and store them in a list.
It seems like this can only be done if you reference each menuItem ID individually in the path (like in the code below).
Is there not a way to say ("menuItem/itemID/itemName") so that I can access each menuItem name dynamically using a for loop with a terminating value equal to the number of menu items in the database?
Any help would be greatly appreciated!
final DatabaseReference _dbRef = FirebaseDatabase.instance.ref();
late DataSnapshot _itemStream;[![enter image description here][1]][1]
Future<List<String>> _readItemNames() async {
_itemStream = await _dbRef.child("menuItem/J1/itemName").get();
itemName = _itemStream.value.toString();
itemNames.addAll([itemName]);
_itemStream = await _dbRef.child("menuItem/J2/itemName").get();
itemName = _itemStream.value.toString();
itemNames.addAll([itemName]);
return itemNames;
}

pushmethod?