ica*_*edo 1 dart firebase firebase-realtime-database flutter
I'm using the Firebase Database plugin to Flutter and I'm trying to get all the data from the "schedules" row.
I have this code and I'm already connected to the Firebase server.
FirebaseDatabase.instance.reference().child('schedules');
Run Code Online (Sandbox Code Playgroud)
My data is stored like this: screenshot of Firebase
I wanted to get the data and insert it on a List so I can use it later.
The data have to be stored like this in Firebase because I need all those 3 values together when I get them. I also wonder if using the Firebase plugin the users will have the ability to update the data (if it is the case) when connected to the internet and see it even when disconnected. Before that I was using httpRequests, but I decided to not use a local storage manager and just see if this plugin could do this for me.
如果它可以做到这一点,那么使用颤振从“计划”中获取所有子数据的正确方法是什么?(数据不显示为列表,所以我不能使用FirebaseAnimatedList)
我会使用 aStreamBuilder以便您的应用程序中依赖于计划列表的部分会在数据更改时自动重建。
return new StreamBuilder<Event>(
stream: FirebaseDatabase.instance.reference().child('schedules').onValue,
builder: (BuildContext context, AsyncSnapshot<Event> event) {
if (!event.hasData)
return new Center(child: new Text('Loading...'));
Map<String, Map> schedules = event.data.snapshot.value;
// Do something with the list of schedules
},
),
Run Code Online (Sandbox Code Playgroud)
如果由于某种原因您只想获得一次计划列表,请使用once()代替onValue和await它的值。
| 归档时间: |
|
| 查看次数: |
1877 次 |
| 最近记录: |