SliverList 和 SliverFixedExtentLi
2020-12-15 本文已影响0人
Albert新荣
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来试验了