SmartRefresher.builder constructor

const SmartRefresher.builder({
  1. Key? key,
  2. required RefreshController controller,
  3. required RefresherBuilder? builder,
  4. bool enablePullDown = true,
  5. bool enablePullUp = false,
  6. VoidCallback? onRefresh,
  7. VoidCallback? onLoading,
  8. bool? enableSmartPreload,
})

创建一个带有下拉刷新和上拉加载功能的组件,使用自定义构建器

适用场景

  • 处理特殊的第三方组件,这些组件需要传递 slivers 但不继承自 ScrollView
  • 避免 scrollable 嵌套 scrollable 的问题
  • 例如:在 NestedScrollView 上方实现刷新(目前 NestedScrollView 不支持边缘过度滚动)

必填参数

  • controller:控制刷新和加载状态的控制器,不能为空
  • builder:自定义内容构建器,不能为空

其他参数

  • enablePullDown:是否启用下拉刷新,默认为 true
  • enablePullUp:是否启用上拉加载,默认为 false
  • onRefresh:下拉刷新回调函数
  • onLoading:上拉加载回调函数

Implementation

const SmartRefresher.builder({
  super.key,
  required this.controller,
  required this.builder,
  this.enablePullDown = true,
  this.enablePullUp = false,
  this.onRefresh,
  this.onLoading,
  this.enableSmartPreload,
})  : header = null,
      footer = null,
      child = null,
      scrollController = null,
      scrollDirection = null,
      physics = null,
      reverse = null,
      semanticChildCount = null,
      dragStartBehavior = null,
      cacheExtent = null,
      primary = null;