Flutter(75):Sliver组件之SliverFixedExtentList
阅读原文时间:2023年07月09日阅读:2

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

著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章