SliverList , SliverFixedExtentList
Posted pythonclub
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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, // ), // ), ], ),
以上是关于SliverList , SliverFixedExtentList的主要内容,如果未能解决你的问题,请参考以下文章
颤振 - SliverList / SliverChildBuilderDelegate 提供初始索引或允许负索引
SliverList 和 Getx StateMixin 支持
Flutter-如何将标题添加到 SliverList 的 SliverChildBuilderDelegate?