build method

  1. @override
Widget build(
  1. BuildContext context, {
  2. Key? key,
  3. Widget? header,
  4. required List<Widget> slivers,
  5. ScrollController? controller,
  6. Future<void> onRefresh()?,
  7. required Clip clipBehavior,
  8. ScrollPhysics? physics,
  9. required bool reverse,
  10. ScrollBehavior? scrollBehavior,
  11. required bool shrinkWrap,
  12. Color? color,
  13. Color? refreshControlBackgroundColor,
  14. Color? refreshIndicatorBackgroundColor,
  15. EdgeInsets padding = EdgeInsets.zero,
})
override

Implementation

@override
Widget build(
  BuildContext context, {
  Key? key,
  Widget? header,
  required List<Widget> slivers,
  ScrollController? controller,
  Future<void> Function()? onRefresh,
  required Clip clipBehavior,
  ScrollPhysics? physics,
  required bool reverse,
  ScrollBehavior? scrollBehavior,
  required bool shrinkWrap,
  Color? color,

  /// The color of the refresh section background. Only for iOS.
  Color? refreshControlBackgroundColor,

  /// The background color of the refresh indicator. Only for Android.
  Color? refreshIndicatorBackgroundColor,
  EdgeInsets padding = EdgeInsets.zero,
}) {
  return CustomScrollView(
    key: key,
    clipBehavior: clipBehavior,
    controller: controller,
    physics: physics,
    reverse: reverse,
    scrollBehavior: scrollBehavior,
    shrinkWrap: shrinkWrap,
    slivers: [
      if (header != null) header,
      if (onRefresh != null)
        CupertinoSliverRefreshControl(
          onRefresh: onRefresh,
          refreshIndicatorExtent: MediaQuery.of(context).padding.top + 60,
          refreshTriggerPullDistance: MediaQuery.of(context).padding.top + 100,
          builder: (context, refreshState, pulledExtent, refreshTriggerPullDistance, refreshIndicatorExtent) {
            return SafeArea(
              child: ColoredBox(
                color: refreshControlBackgroundColor ?? Colors.transparent,
                child: CupertinoSliverRefreshControl.buildRefreshIndicator(
                  context,
                  refreshState,
                  pulledExtent,
                  refreshTriggerPullDistance,
                  refreshIndicatorExtent,
                ),
              ),
            );
          },
        ),
      SliverPadding(
        padding: padding,
        sliver: SliverMainAxisGroup(slivers: slivers),
      )
    ],
  );
}