How to query in a Flutter/FirebaseAnimatedList using buildArguments or anything else? (example please)

后端 未结 2 1132
Happy的楠姐
Happy的楠姐 2020-12-18 07:38

I have a this Scaffold with body:

body: new Column(
        children: [
          new Flexible(
            child: new FirebaseAni         


        
2条回答
  •  不知归路
    2020-12-18 08:12

    Ok, following your guide (@ChennaReddy and @aziza), this is the way I fix my code:

    body: new Column(
            children: [
              new Flexible(
                child: new FirebaseAnimatedList(
                  query: FirebaseDatabase.instance
                      .reference()
                      .child('products')
                      .orderByChild('Active')           // line changed
                      .equalTo(true),                   // line added
                  padding: new EdgeInsets.all(8.0),
                  reverse: false,
                  itemBuilder: (_, DataSnapshot snapshot,
                      Animation animation, int x) {
                    return new ProductItem(
                        snapshot: snapshot, animation: animation);
                  },
                ),
              ),
            ],
          ),
    

    However, I need the resulting query order by 'order' which is a integer field (or attribute) that some admin users can change (update). So final users can see data ordered by 'order' (but only 'Active'=true as you help me to solve).

提交回复
热议问题