English 中文(简体)
How to write to second tree in Firebase Realtime Database
原标题:

I have a Firebase Realtime Database and I want to write to it, that s simple enough, but I have added more than one tree to my Database and want to know how to write to the second tree. Right now I can only write to the first tree.

Image for better understanding: enter image description here

So for example how can I write to the Color info.

Note: The first line of string (User line in image) is the users id token (currentFirebaseUser.uid) //uid = User ID and the second line of string(Info line in image) is automatically generated by firebase

Database code:

  _getDBRides() {
    return Expanded(
      child: FirebaseAnimatedList(
        query: dbRef,
        itemBuilder: (BuildContext context, DataSnapshot snapshot,
            Animation<double> animation, int index) {
          Map Rides = snapshot.value as Map;
          //unique key/id of each item in db
          Rides[ key ] = snapshot.key;
          return listItem(Rides: Rides);
        },
      ),
    );
  }`

Button(
  onTap: () {
    if (_validateDate() == true) {
      ref.child( Rides/${user.uid} ).push().set({
        //Info saved in database
      }).asStream();
      _titleController.clear();
    }
  },
),

If there is one tree in the database then I can reference it like this

Rides[ Color ]

But because there is another tree I don t know how to write to it

What I have tried: Rides[ key ][ Color ] doesn t work

Seems short but I have tried writing it in different ways too to see how to write to that tree but nothing work and the documentation doesn t seem to show how to write to a second tree.

问题回答

暂无回答




相关问题
Flutter App cannot be installed on Android TV

I m building a Flutter app that should support Android TV and Mobile devices. Despite Google Play shows that it is supported, I cannot install app on my MiBox device. While trying to install it, both ...

Moving the icon button to the right causes rendering issues

I am trying to align the icon button to the right of the Text field, I tried the row which made the icon button not centered vertically and now I am trying out the Stack widget. Here is my code - ...

热门标签