contentBuilder method

  1. @override
Widget contentBuilder(
  1. BuildContext context,
  2. RefreshMode refreshState,
  3. double pulledExtent,
  4. double refreshTriggerPullDistance,
  5. double refreshIndicatorExtent,
  6. AxisDirection axisDirection,
  7. bool float,
  8. Duration? completeDuration,
  9. bool enableInfiniteRefresh,
  10. bool success,
  11. bool noMore,
)

Implementation

@override
Widget contentBuilder(
    BuildContext context,
    RefreshMode refreshState,
    double pulledExtent,
    double refreshTriggerPullDistance,
    double refreshIndicatorExtent,
    AxisDirection axisDirection,
    bool float,
    Duration? completeDuration,
    bool enableInfiniteRefresh,
    bool success,
    bool noMore) {
  // print(
  //     '$refreshState  拉动距离:$pulledExtent 触发刷新距离:$refreshTriggerPullDistance Header的高度:$refreshIndicatorExtent');

  if (refreshState == RefreshMode.refreshed && success) {
    return const Center(child: Text('refresh success!'));
  }
  if (refreshState == RefreshMode.inactive) {
    return const SizedBox();
  }
  switch (refreshState) {
    case RefreshMode.drag:
      if (pulledExtent <= 20) {
        return const SizedBox();
      }
      return Container(
        alignment: Alignment.bottomCenter,
        child: AnimatedSwitcher(
          duration: const Duration(milliseconds: 300),
          child: pulledExtent <= refreshTriggerPullDistance
              ? const Icon(
            Icons.arrow_downward_outlined,
          )
              : const Icon(
            Icons.arrow_upward_outlined,
          ),
        ),
      );

  /// 刷新中状态。
    case RefreshMode.refresh:
      return SizedBox(
        height: refreshIndicatorExtent,
        child: Center(child: kLoadingWidgetWithRefresh),
      );

  /// 可以执行刷新的操作了,直接返回一个loading。
    case RefreshMode.armed:
      return Center(
        child: kLoadingWidgetWithRefresh,
      );
    default:
      return Container();
  }
}