【发布时间】:2018-04-05 09:07:24
【问题描述】:
我有一个带有正文的Scaffold:
body: new Column(
children: <Widget>[
new Flexible(
child: new FirebaseAnimatedList(
query: FirebaseDatabase.instance
.reference()
.child('products')
.orderByChild('order'),
padding: new EdgeInsets.all(8.0),
reverse: false,
itemBuilder: (_, DataSnapshot snapshot,
Animation<double> animation, int x) {
return new ProductItem(
snapshot: snapshot, animation: animation);
},
),
),
],
),
但我需要添加一个简单的查询:'Active' = true
有可能吗?如何?任何示例/教程?
谢谢。
【问题讨论】:
-
由于您想通过“活动”字段进行查询,根据您存储活动字段的方式,您的查询应该类似于
FirebaseDatabase.instance .reference().child('active').equalTo(true)或FirebaseDatabase.instance .reference().child('active').equalTo('true')。我可以知道使用 orderByChild('order') 的动机是什么吗?为什么是查询的一部分? -
@ChennaReddy,我需要按“订单”生成的查询顺序,这是一个整数字段(或属性),一些管理员用户可以更改(更新)。所以最终用户可以看到按“顺序”排序的数据(但只有 'Active'=true,因为你帮我解决了)。
标签: firebase firebase-realtime-database dart flutter