SliverList , SliverFixedExtentList

 

SliverList 高度自动,
SliverFixedExtentList 高度固定死.
CustomScrollView(
              slivers:[
                
                SliverList(
                  delegate: SliverChildBuilderDelegate((context, int index){
                    Container postPiece;
                    if (index == 0){
                      postPiece = Container(
                        child: Text('$index , aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', style: TextStyle(color: Colors.grey),),
                      );
                    } else {
                      postPiece = Container(
                        child: Text('$index, bbbbbbbbbbbbb', 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('dsssouu',style: TextStyle(color: Colors.black),),
//                      );
//                    }else{
//                      _piece = Container(
//                        child: Text('aaaa', style: TextStyle(color: Colors.grey),),
//                      );
//                    }
//                    return _piece;
//                  },
//                    childCount: 20,
//                  ),
//                ),

            ],
            ),

  

    原文作者:CrossPython
    原文地址: https://www.cnblogs.com/pythonClub/p/10659521.html
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞