Firebaseanimatelist中的“不同的第一项" [英] Different First Item, in Firebaseanimiatedlist

查看:84
本文介绍了Firebaseanimatelist中的“不同的第一项"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下面的代码来包含所有物品清单,但我需要在顶部显示一个卡片物品,该物品应该与Firebaseanimatedlist一起滚动,但是该卡片仅对第一物品可见.

I have below code to include all the list of items but i need to display a card item on top, which should be scrollable along with Firebaseanimatedlist, but the card should be visible only for the First Item.

我该如何做到这一点.使用下面的代码,Card()停留在顶部,并且不会在支架中滚动.

How can i achieve this. With the below code, Card() sticks at the top and does not scroll in the scaffold.

return getContent() {
  return new Container(
    child: new Column(
      children: <Widget>[
         new Card(
                child: new Text("STATIC ITEM TO DISPLAY ON TOP AS A HEADER FOR BELOW FIREBAE LIST"),
                 ),
         new Flexible(
          child: new FirebaseAnimatedList(
            query: Your database reference,
            itemBuilder: (_, DataSnapshot snapshot, Animation<double> 
            animation, int index) {
               return new Column();
            }
          ),
        )
      ]
    )
  );
}

推荐答案

int索引返回列表中的每个元素0、1、2、3、4 ...,具体取决于元素您可以告诉它为每个设计返回不同的设计.

The int index returns every element of the list, 0, 1, 2, 3, 4 ... depending on the elements you can tell it to return a different design for each one.

我不知道这是否是最好的方法,但我认为这是值得的.

I do not know if it's the best way to do it, but I think it could be worth it.

return getContent() {
  return new Container(
    child: new Column(
      children: <Widget>[
         new Flexible(
          child: new FirebaseAnimatedList(
            query: Your database reference,
            itemBuilder: (_, DataSnapshot snapshot, Animation<double> 
            animation, int index) {
               if(index==0){
                  return new Column(
                    children: <Widget>[
                      new Card(
                       child: new Text("STATIC ITEM TO DISPLAY ON TOP AS A 
                       HEADER FOR BELOW FIREBAE LIST"),
                      ),
                    ]
                  );
               } else {
                 return new Column();
               }
            }
          ),
        )
      ]
    )
  );
}

这篇关于Firebaseanimatelist中的“不同的第一项"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆