flutter3.0学习笔记

CustomScrollView

Preview

CustomScrollView是可以使用Sliver来自定义滚动模型(效果)的组件。它可以包含多种滚动模型。CustomScrollView 的主要功能是提供一个公共的的 ScrollableViewport,来组合多个 Sliver。其构造:

const CustomScrollView({
    super.key,
    super.scrollDirection,
    super.reverse,
    super.controller,
    super.primary,
    super.physics,
    super.scrollBehavior,
    super.shrinkWrap,
    super.center,
    super.anchor,
    super.cacheExtent,
    this.slivers = const <Widget>[],
    super.semanticChildCount,
    super.dragStartBehavior,
    super.keyboardDismissBehavior,
    super.restorationId,
    super.clipBehavior,
  });

用法:

CustomScrollView(
    slivers: [
      SliverAppBar(...),
      SliverToBoxAdapter(...),
      SliverGrid(...),
      SliverToBoxAdapter(...),
      SliverFixedExtenrList(...),
    ],
    controller: ScrollController(),
)