Flutter(75):Sliver组件之SliverFixedExtentList
Flutter教学目录持续更新中Github源代码持续更新中1.SliverFixedExtentList可以固定Item高度的SliverList2.SliverFixedExtentListdelegate:SliverChildDelegateitemExtent:item高度3.使用这个就是比SliverList多了item高度控制:Flutter(72):Sliver组件之SliverL
·
Flutter教学目录持续更新中
Github源代码持续更新中
1.SliverFixedExtentList
可以固定Item高度的SliverList
2.SliverFixedExtentList
- delegate:SliverChildDelegate
- itemExtent:item高度
3.使用
这个就是比SliverList多了item高度控制:Flutter(72):Sliver组件之SliverList
这里item内子控件高度是200,但是我们SliverFixedExtentList约束为100,那么item高度就会是100,如果内部高度小于100也一样会强制变为100
_mySliverAppBar() {
return SliverAppBar(
title: Text('SliverFixedExtentList'),
expandedHeight: 250,
flexibleSpace: FlexibleSpaceBar(
background: Image.network(
ImageUrlConstant.imageUrl1,
fit: BoxFit.cover,
),
collapseMode: CollapseMode.parallax,
),
);
}
_mySliverChildBuilderDelegate() {
return SliverChildBuilderDelegate(
(BuildContext context, int index) {
return Container(
height: 200,
color: Colors.primaries[index % 11],
);
},
childCount: 30,
);
}
@override
Widget build(BuildContext context) {
return Container(
color: Colors.white,
child: CustomScrollView(
slivers: [
SliverFixedExtentList(
delegate: _mySliverChildBuilderDelegate(),
itemExtent: 100,
),
],
),
);
}

image.png
Flutter教学目录持续更新中
Github源代码持续更新中
作者:http://www.hbfzb.com/news.php
链接:http://www.autono1.com/
来源:http://szgc.glodon.com/news.php
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
更多推荐


所有评论(0)