From 480a082766c47bf238807455e986aa33ca771ee1 Mon Sep 17 00:00:00 2001 From: Haeseok Lee Date: Sat, 19 Sep 2020 06:32:04 +0900 Subject: [PATCH] Add dart-pad example code for CupertinoSliverRefreshControl (#65164) --- .../flutter/lib/src/cupertino/refresh.dart | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/packages/flutter/lib/src/cupertino/refresh.dart b/packages/flutter/lib/src/cupertino/refresh.dart index 119b6ad80e..2b2300bdfb 100644 --- a/packages/flutter/lib/src/cupertino/refresh.dart +++ b/packages/flutter/lib/src/cupertino/refresh.dart @@ -268,6 +268,60 @@ typedef RefreshCallback = Future Function(); /// sliver such as [CupertinoSliverNavigationBar] and your main scrollable /// content's sliver. /// +/// {@tool dartpad --template=stateful_widget_material} +/// +/// When the user scrolls past [refreshTriggerPullDistance], +/// this sample shows the default ios pull to refresh indicator for 1 second and +/// adds a new item to the top of the list view. +/// +/// ```dart imports +/// import 'package:flutter/cupertino.dart'; +/// ``` +/// +/// ```dart +/// List colors = [ +/// CupertinoColors.systemYellow, +/// CupertinoColors.systemOrange, +/// CupertinoColors.systemPink +/// ]; +/// List items = [ +/// Container(color: CupertinoColors.systemPink, height: 100.0), +/// Container(color: CupertinoColors.systemOrange, height: 100.0), +/// Container(color: CupertinoColors.systemYellow, height: 100.0), +/// ]; +/// +/// @override +/// Widget build(BuildContext context) { +/// return CupertinoApp( +/// home: CupertinoPageScaffold( +/// child: CustomScrollView( +/// physics: const BouncingScrollPhysics(parent: AlwaysScrollableScrollPhysics()), +/// slivers: [ +/// const CupertinoSliverNavigationBar(largeTitle: Text('Scroll down')), +/// CupertinoSliverRefreshControl( +/// refreshTriggerPullDistance: 100.0, +/// refreshIndicatorExtent: 60.0, +/// onRefresh: () async { +/// await Future.delayed(Duration(milliseconds: 1000)); +/// setState(() { +/// items.insert(0, Container(color: colors[items.length % 3], height: 100.0)); +/// }); +/// }, +/// ), +/// SliverList( +/// delegate: SliverChildBuilderDelegate( +/// (BuildContext context, int index) => items[index], +/// childCount: items.length, +/// ), +/// ), +/// ], +/// ) +/// ) +/// ); +/// } +/// ``` +/// {@end-tool} +/// /// See also: /// /// * [CustomScrollView], a typical sliver holding scroll view this control