1. const SliverChildBuilderDelegate(
    2. this.builder, // 创建子元素 (BuildContext context, int index){return build}
    3. {
    4. this.findChildIndexCallback, // 调用它,以便在重新排序时根据子元素的键查找新索引。如果没有提供,当子部件从[builder]返回的顺序发生变化时,子部件可能不会映射到它现有的[RenderObject]。这可能会导致状态损失。这个回调函数应该接受一个input [Key],它应该返回子元素的索引(如果没有找到)。
    5. this.childCount,// 限制子孩子的个数
    6. this.addAutomaticKeepAlives = true,
    7. this.addRepaintBoundaries = true,
    8. this.addSemanticIndexes = true,
    9. this.semanticIndexCallback = _kDefaultSemanticIndexCallback,
    10. this.semanticIndexOffset = 0,
    11. }) : assert(builder != null),
    12. assert(addAutomaticKeepAlives != null),
    13. assert(addRepaintBoundaries != null),
    14. assert(addSemanticIndexes != null),
    15. assert(semanticIndexCallback != null);

    基本用法

    1. return CustomScrollView(
    2. slivers: <Widget>[
    3. SliverAppBar(
    4. expandedHeight: 200.0,
    5. pinned: true, // 当滑动到底部的时候则显示标题
    6. leading: IconButton(icon: Icon(Icons.arrow_back_ios), color: Colors.red, onPressed: (){
    7. }),
    8. backgroundColor: Colors.black,
    9. flexibleSpace: FlexibleSpaceBar( // 背景
    10. title: Text('娜扎之魔童降世', style: TextStyle(
    11. color: Color(0xffe5e5e5),
    12. fontSize: 16,
    13. ),),
    14. background: Image.network(
    15. 'https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=3254228255,2309346508&fm=26&gp=0.jpg',
    16. fit: BoxFit.fitHeight, // 沾满真个高度
    17. ),
    18. ),
    19. ),
    20. // SliverList(
    21. // delegate: SliverChildBuilderDelegate((content, index) {
    22. // return Container(
    23. // height: 65,
    24. // color: Colors.primaries[index % Colors.primaries.length],
    25. // );
    26. // }, childCount: 5),
    27. // )
    28. SliverFixedExtentList(
    29. delegate: SliverChildBuilderDelegate(
    30. (BuildContext context, int index){
    31. return Card(
    32. child: Container(
    33. alignment: Alignment.center,
    34. color: Colors.primaries[(index % 18)],
    35. child: Text(index.toString()),
    36. ),
    37. );
    38. },
    39. childCount: 7, // 如不设置则无限个子孩子
    40. findChildIndexCallback: (key) => 0,
    41. semanticIndexOffset: 2
    42. ),
    43. itemExtent: 80.0)
    44. ],
    45. );

    simulator_screenshot_2B2FCAF1-D165-404C-8928-A31AD4226424.pngsimulator_screenshot_3171BF50-B4E5-4483-BAFF-58756FA439D6.pngsimulator_screenshot_F5B053A9-2AA2-44BF-BF45-BA46138F39B9.png