美文网首页
SliverList 和 SliverFixedExtentLi

SliverList 和 SliverFixedExtentLi

作者: Albert新荣 | 来源:发表于2020-12-15 19:12 被阅读0次

    sliverList 高度自动
    sliverFixedExtentList 高度死的

    SliverList(
                      delegate: SliverChildBuilderDelegate((context, int index){
                        Container postPiece;
                        if (index == 0){
                          postPiece = Container(
                            child: Text('$index,高度是活的哦', style: TextStyle(color: Colors.grey),),
                          );
                        } else {
                          postPiece = Container(
                            child: Text('$index, 另一个容器啊', style: TextStyle(color: Colors.black),),
                          );
                        }
                        return postPiece;
                      },
                        childCount: 100,
                      ),
                    ),
    
    SliverFixedExtentList(
                      itemExtent: 50, //child的长度或者宽度,取决于滚动方向.
                delegate: SliverChildBuilderDelegate((context, int index) {
                       print(content.mainPost);
                     Container _piece;
                        if (index == 0){
                       _piece = Container(
                       child: Text('第一个',style: TextStyle(color: Colors.black),),
                        );
                       }else{
                         _piece = Container(
                            child: Text('另外一个', style: TextStyle(color: Colors.grey),),
                         );
                        }
                       return _piece;
                      },
                        childCount: 20,
                      ),
                   ),
    

    这边文章根据 https://www.cnblogs.com/pythonClub/p/10659521.html来试验了

    相关文章

      网友评论

          本文标题:SliverList 和 SliverFixedExtentLi

          本文链接:https://www.haomeiwen.com/subject/ggowgktx.html