Code Monkey home page Code Monkey logo

pull_to_refresh_notification's Introduction

pull_to_refresh_notification

pub package GitHub stars GitHub forks GitHub license GitHub issues flutter-candies

Language: English | 中文简体

widget to build pull to refresh effects.

Web demo for PullToRefreshNotification

Chinese blog

RefreshIndicatorMode

enum RefreshIndicatorMode {
  drag, // Pointer is down.
  armed, // Dragged far enough that an up event will run the onRefresh callback.
  snap, // Animating to the indicator's final "displacement".
  refresh, // Running the refresh callback.
  done, // Animating the indicator's fade-out after refreshing.
  canceled, // Animating the indicator's fade-out after not arming.
  error, //refresh failed
}

Sample 1 appbar

build appbar to pull to refresh with PullToRefreshContainer

   Widget build(BuildContext context) {
 return PullToRefreshNotification(
      color: Colors.blue,
      pullBackOnRefresh: true,
      onRefresh: onRefresh,
      child: CustomScrollView(
        slivers: <Widget>[
          PullToRefreshContainer(buildPulltoRefreshAppbar),
          SliverList(
              delegate:
                  SliverChildBuilderDelegate((BuildContext context, int index) {
            return Container(
                padding: EdgeInsets.only(bottom: 4.0),
                child: Column(
                  children: <Widget>[
                    Text(
                      "List item : ${listlength - index}",
                      style: TextStyle(fontSize: 15.0, inherit: false),
                    ),
                    Divider(
                      color: Colors.grey,
                      height: 2.0,
                    )
                  ],
                ));
          }, childCount: listlength)),
        ],
      ),
    );
}
    
     Widget buildPulltoRefreshAppbar(PullToRefreshScrollNotificationInfo info) {
        var action = Padding(
          child: info?.refreshWidget ?? Icon(Icons.more_horiz),
          padding: EdgeInsets.all(15.0),
        );
        var offset = info?.dragOffset ?? 0.0;
        return SliverAppBar(
            pinned: true,
            title: Text("PullToRefreshAppbar"),
            centerTitle: true,
            expandedHeight: 200.0 + offset,
            actions: <Widget>[action],
            flexibleSpace: FlexibleSpaceBar(
                //centerTitle: true,
                title: Text(
                  info?.mode?.toString() ?? "",
                  style: TextStyle(fontSize: 10.0),
                ),
                collapseMode: CollapseMode.pin,
                background: Image.asset(
                  "assets/467141054.jpg",
                  //fit: offset > 0.0 ? BoxFit.cover : BoxFit.fill,
                  fit: BoxFit.cover,
                )));
      }

Sample 2 header

build header to pull to refresh with PullToRefreshContainer. and you can easy to handle the status in pulling.

  Widget build(BuildContext context) {
    return PullToRefreshNotification(
       color: Colors.blue,
       onRefresh: onRefresh,
       maxDragOffset: 80.0,
       child: CustomScrollView(
         slivers: <Widget>[
           SliverAppBar(
             pinned: true,
             title: Text("PullToRefreshHeader"),
           ),
           PullToRefreshContainer(buildPulltoRefreshHeader),
           SliverList(
               delegate:
                   SliverChildBuilderDelegate((BuildContext context, int index) {
             return Container(
                 padding: EdgeInsets.only(bottom: 4.0),
                 child: Column(
                   children: <Widget>[
                     Text(
                       "List item : ${listlength - index}",
                       style: TextStyle(fontSize: 15.0, inherit: false),
                     ),
                     Divider(
                       color: Colors.grey,
                       height: 2.0,
                     )
                   ],
                 ));
           }, childCount: listlength)),
         ],
       ),
     );
   }
 
   Widget buildPulltoRefreshHeader(PullToRefreshScrollNotificationInfo info) {
     var offset = info?.dragOffset ?? 0.0;
     var mode = info?.mode;
     Widget refreshWidget = Container();
     //it should more than 18, so that RefreshProgressIndicator can be shown fully
     if (info?.refreshWidget != null &&
         offset > 18.0 &&
         mode != RefreshIndicatorMode.error) {
       refreshWidget = info.refreshWidget;
     }
 
     Widget child = null;
     if (mode == RefreshIndicatorMode.error) {
       child = GestureDetector(
           onTap: () {
             // refreshNotification;
             info?.pullToRefreshNotificationState?.show();
           },
           child: Container(
             color: Colors.grey,
             alignment: Alignment.bottomCenter,
             height: offset,
             width: double.infinity,
             //padding: EdgeInsets.only(top: offset),
             child: Container(
               padding: EdgeInsets.only(left: 5.0),
               alignment: Alignment.center,
               child: Text(
                 mode?.toString() + "  click to retry" ?? "",
                 style: TextStyle(fontSize: 12.0, inherit: false),
               ),
             ),
           ));
     } else {
       child = Container(
         color: Colors.grey,
         alignment: Alignment.bottomCenter,
         height: offset,
         width: double.infinity,
         //padding: EdgeInsets.only(top: offset),
         child: Row(
           mainAxisAlignment: MainAxisAlignment.center,
           children: <Widget>[
             refreshWidget,
             Container(
               padding: EdgeInsets.only(left: 5.0),
               alignment: Alignment.center,
               child: Text(
                 mode?.toString() ?? "",
                 style: TextStyle(fontSize: 12.0, inherit: false),
               ),
             )
           ],
         ),
       );
     }
 
     return SliverToBoxAdapter(
       child: child,
     );
   }

Sample 3 image

build zoom image to pull to refresh with using PullToRefreshContainer.

 Widget build(BuildContext context) {
     return PullToRefreshNotification(
       color: Colors.blue,
       pullBackOnRefresh: true,
       onRefresh: onRefresh,
       child: CustomScrollView(
         slivers: <Widget>[
           SliverAppBar(
             title: Text("PullToRefreshImage"),
           ),
           PullToRefreshContainer(buildPulltoRefreshImage),
           SliverList(
               delegate:
                   SliverChildBuilderDelegate((BuildContext context, int index) {
             return Container(
                 padding: EdgeInsets.only(bottom: 4.0),
                 child: Column(
                   children: <Widget>[
                     Text(
                       "List item : ${listlength - index}",
                       style: TextStyle(fontSize: 15.0, inherit: false),
                     ),
                     Divider(
                       color: Colors.grey,
                       height: 2.0,
                     )
                   ],
                 ));
           }, childCount: listlength)),
         ],
       ),
     );
   }
   
   Widget buildPulltoRefreshImage(PullToRefreshScrollNotificationInfo info) {
     var offset = info?.dragOffset ?? 0.0;
     Widget refreshWidget = Container();
     if (info?.refreshWidget != null) {
       refreshWidget = Material(
         type: MaterialType.circle,
         color: Theme.of(context).canvasColor,
         elevation: 2.0,
         child: Padding(
           padding: EdgeInsets.all(12),
           child: info.refreshWidget,
         ),
       );
     }
 
     return SliverToBoxAdapter(
       child: Stack(
         alignment: Alignment.center,
         children: <Widget>[
           Container(
               height: 200.0 + offset,
               width: double.infinity,
               child: Image.asset(
                 "assets/467141054.jpg",
                 //fit: offset > 0.0 ? BoxFit.cover : BoxFit.fill,
                 fit: BoxFit.cover,
               )),
           Center(
             child: Row(
               mainAxisAlignment: MainAxisAlignment.center,
               children: <Widget>[
                 refreshWidget,
                 Container(
                   padding: EdgeInsets.only(left: 5.0),
                   alignment: Alignment.center,
                   child: Text(
                     info?.mode?.toString() ?? "",
                     style: TextStyle(fontSize: 12.0, inherit: false),
                   ),
                 )
               ],
             ),
           )
         ],
       ),
     );
   }

Sample 4 candies

build candies animation to pull to refresh with using PullToRefreshContainer.

  Widget build(BuildContext context) {
    return Material(
      child: Stack(
        children: <Widget>[
          PullToRefreshNotification(
            color: Colors.blue,
            onRefresh: onRefresh,
            maxDragOffset: maxDragOffset,
            armedDragUpCancel: false,
            key: key,
            child: CustomScrollView(
              ///in case list is not full screen and remove ios Bouncing
              physics: AlwaysScrollableClampingScrollPhysics(),
              slivers: <Widget>[
                SliverAppBar(
                  title: Text("PullToRefreshCandies"),
                ),
                PullToRefreshContainer((info) {
                  var offset = info?.dragOffset ?? 0.0;
                  Widget child = Container(
                    alignment: Alignment.center,
                    height: offset,
                    width: double.infinity,
                    child: RefreshLogo(
                      mode: info?.mode,
                      offset: offset,
                    ),
                  );

                  return SliverToBoxAdapter(
                    child: child,
                  );
                }),
                SliverList(
                    delegate: SliverChildBuilderDelegate(
                        (BuildContext context, int index) {
                  return Container(
                      padding: EdgeInsets.only(bottom: 4.0),
                      child: Column(
                        children: <Widget>[
                          Text(
                            "List item : ${listlength - index}",
                            style: TextStyle(fontSize: 15.0),
                          ),
                          Divider(
                            color: Colors.grey,
                            height: 2.0,
                          )
                        ],
                      ));
                }, childCount: listlength)),
              ],
            ),
          ),
          Positioned(
            right: 20.0,
            bottom: 20.0,
            child: FloatingActionButton(
              child: Icon(Icons.refresh),
              onPressed: () {
                key.currentState.show(notificationDragOffset: maxDragOffset);
              },
            ),
          )
        ],
      ),
    );
  }

Sample 5 candies

Show how to use pull to refresh notification for reverse list like chat list.

        PullToRefreshNotification(
          onRefresh: onRefresh,
          maxDragOffset: 48,
          armedDragUpCancel: false,
          reverse: true,
          child: Column(
            children: <Widget>[
              PullToRefreshContainer(
                  (PullToRefreshScrollNotificationInfo info) {
                final double offset = info?.dragOffset ?? 0.0;

                //loading history data
                return Container(
                  height: offset,
                  child: const RefreshProgressIndicator(
                    valueColor: AlwaysStoppedAnimation<Color>(Colors.blue),
                    strokeWidth: 2.0,
                  ),
                );
              }),
              Expanded(
                child: ExtendedListView.builder(
                  ///in case list is not full screen and remove ios Bouncing
                  physics: const AlwaysScrollableClampingScrollPhysics(),
                  reverse: true,
                  extendedListDelegate:
                      const ExtendedListDelegate(closeToTrailing: true),
                  itemBuilder: (BuildContext context, int index) {
                    List<Widget> children = <Widget>[
                      Text('$index. ${chats[index]}'),
                      Image.asset(
                        'assets/avatar.jpg',
                        width: 30,
                        height: 30,
                      ),
                    ];
                    if (index % 2 == 0) {
                      children = children.reversed.toList();
                    }
                    return Row(
                      mainAxisAlignment: index % 2 == 0
                          ? MainAxisAlignment.start
                          : MainAxisAlignment.end,
                      children: children,
                    );
                  },
                  itemCount: chats.length,
                ),
              )
            ],
          ),
        ),

refresh with code

  • define key
  final GlobalKey<PullToRefreshNotificationState> key =
      new GlobalKey<PullToRefreshNotificationState>();

        PullToRefreshNotification(
          key: key,    
  • use key

if you define pull Container hegith with dragOffset, you need set notificationDragOffset when refresh.

  key.currentState.show(notificationDragOffset: maxDragOffset);

pull_to_refresh_notification's People

Contributors

bemacized avatar zmtzawqlp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pull_to_refresh_notification's Issues

嵌套nested_scrollview刷新过程中,下啦往上滚动,会触发bug

Version

3.0.1

Platforms

dart, Android, iOS

Device Model

iPhone13

flutter info

[✓] Flutter (Channel stable, 3.10.4, on macOS 12.6.3 21G419 darwin-x64, locale zh-Hans-CN)
    • Flutter version 3.10.4 on channel stable at /Users/ljz/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 682aa387cf (2 weeks ago), 2023-06-05 18:04:56 -0500
    • Engine revision 2a3401c9bb
    • Dart version 3.0.3
    • DevTools version 2.23.1
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/ljz/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • ANDROID_HOME = /Users/ljz/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14C18
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[✓] IntelliJ IDEA Ultimate Edition (version 2021.2.3)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 69.0.2
    • Dart plugin version 212.5632

[✓] IntelliJ IDEA Ultimate Edition (version 2019.3.1)
    • IntelliJ at /Users/ljz/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] IntelliJ IDEA Ultimate Edition (version 2019.3.1)
    • IntelliJ at /Users/ljz/Library/Application
      Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/193.5662.53/IntelliJ IDEA.app
    • Flutter plugin version 45.1.2
    • Dart plugin version 193.7547

[✓] VS Code (version 1.79.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.66.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 12.6.3 21G419 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 114.0.5735.133

[✓] Network resources
    • All expected network resources are available.

• No issues found!

How to reproduce?

嵌套nested_scrollview刷新过程中,下啦往上滚动,会触发bug

Logs

══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
The following assertion was thrown during performLayout():
'package:extended_nested_scroll_view/src/extended_nested_scroll_view.dart': Failed assertion: line
1045 pos 16: 'extra <= 0.0': is not true.

The relevant error-causing widget was:
  ExtendedNestedScrollView
  ExtendedNestedScrollView:file:///Users/ljz/Documents/jiyun/new-app/lib/components/custom_refresh/custom_refresh.dart:86:16

When the exception was thrown, this was the stack:
#2      _NestedScrollCoordinator._getMetrics (package:extended_nested_scroll_view/src/extended_nested_scroll_view.dart:1045:16)
extended_nested_scroll_view.dart:1045
#3      _NestedScrollCoordinator.createOuterBallisticScrollActivity (package:extended_nested_scroll_view/src/extended_nested_scroll_view.dart:963:42)
extended_nested_scroll_view.dart:963
#4      _NestedOuterBallisticScrollActivity.applyNewDimensions (package:extended_nested_scroll_view/src/extended_nested_scroll_view.dart:1787:19)
extended_nested_scroll_view.dart:1787
#5      ScrollPosition.applyNewDimensions (package:flutter/src/widgets/scroll_position.dart:621:15)
scroll_position.dart:621
#6      _NestedScrollPosition.applyNewDimensions (package:extended_nested_scroll_view/src/extended_nested_scroll_view.dart:1701:11)
extended_nested_scroll_view.dart:1701
#7      _ExtendedNestedScrollPosition.applyNewDimensions (package:extended_nested_scroll_view/src/extended_nested_scroll_view_part.dart:272:11)
extended_nested_scroll_view_part.dart:272
#8      ScrollPosition.applyContentDimensions (package:flutter/src/widgets/scroll_position.dart:551:7)
scroll_position.dart:551
#9      _ExtendedNestedScrollPosition.applyContentDimensions (package:extended_nested_scroll_view/src/extended_nested_scroll_view_part.dart:284:18)
extended_nested_scroll_view_part.dart:284
#10     RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1424:20)
viewport.dart:1424
#11     RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:2234:7)
object.dart:2234
#12     PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1016:18)
object.dart:1016
#13     RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:492:19)
binding.dart:492
#14     WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:905:13)
binding.dart:905
#15     RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:358:5)
binding.dart:358
#16     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1284:15)
binding.dart:1284
#17     SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1214:9)
binding.dart:1214
#18     SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1072:5)
binding.dart:1072
#19     _invoke (dart:ui/hooks.dart:142:13)
hooks.dart:142
#20     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:359:5)
platform_dispatcher.dart:359
#21     _drawFrame (dart:ui/hooks.dart:112:31)
hooks.dart:112
(elided 2 frames from class _AssertionError)

Example code (optional)

No response

Contact

No response

Nested scroll

Hello! I have a vertical CustomScrollView wrapped with PullToRefreshNotification, and inside CustomScrollView there is a widget with horizontal SingleChildScrollView. Which of them PullToRefreshNotification will be listening to? Does it work correctly? Thanks.

support flutter 3.10

dependency_overrides:

pull_to_refresh_notification: 
  git: 
    url: https://github.com/mdddj/pull_to_refresh_notification

为什么我设置的滑动监听,没有反应?

代码如下,打印一直没有输出。

Scaffold( appBar: new MyAppBar( child: Container( color: Colors.white30, child: Text("Title"), ), ), body: PullToRefreshNotification( onRefresh: _onRefresh, maxDragOffset: 250.0, notificationPredicate: (info) { print("---1----->${info?.metrics?.pixels}"); return true; }, child: CustomScrollView( controller: _scrollControler, slivers: <Widget>[ PullToRefreshContainer((info) { var offset = info?.dragOffset ?? 0.0; return SliverToBoxAdapter( child: Stack( children: <Widget>[ new Container( height: 240 + offset, width: double.infinity, child: Image.asset( "images/img_mine_top_bg.jpg", fit: BoxFit.cover, ), ), ], ), ); }), SliverList( delegate: SliverChildListDelegate(_listItem()), ) ], ), ), );

希望可以开放部分参数

希望可以开放此参数

// When the scroll ends, the duration of the refresh indicator's animation
// to the RefreshIndicator's displacement.
const Duration _kIndicatorSnapDuration = Duration(milliseconds: 150);

有些需求只是下拉放大图片。

现在回弹需要等待该时长。

很怪

[3.13.0] 出错了 ,求更新下

Content

pub.dev/pull_to_refresh_notification-3.0.1/lib/src/pull_to_refresh_notification.dart:326:20:
Error: The method 'disallowGlow'
isn't defined for
the class 'OverscrollIndicatorNotification'.

滚动条 jumpTo到顶部 会触发刷新

headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
          return [
            SliverAppBar(
              // forceElevated: innerBoxIsScrolled,
              title: Text(widget.title),
              actions: widget.actions,
              flexibleSpace: widget.flexibleSpace,
              expandedHeight: widget.expandedHeight,
            ),
            PullToRefreshContainer((info) => PullToRefreshHeader(info: info)),
            SliverTabBar(
              child: TabBar(
                controller: tabController,
                isScrollable: widget.isScrollable,
                onTap: (int index) => tabBarOnTap(context, index),
                tabs: [
                  for (final tab in widget.tabs) Tab(child: Text(tab.name)),
                ],
              ),
              pinned: true,
            ),
          ];
        }
PrimaryScrollController.of(context)!.jumpTo(widget.expandedHeight ?? 0);

报错'_notificationDragOffset == null': is not true.

有强迫症,能不让它报错吗


════════ Exception caught by gesture ═══════════════════════════════════════════════════════════════
The following assertion was thrown while handling a gesture:
'package:pull_to_refresh_notification/src/pull_to_refresh_notification.dart': Failed assertion: line 287 pos 12: '_notificationDragOffset == null': is not true.

When the exception was thrown, this was the stack: 
#2      PullToRefreshNotificationState._start (package:pull_to_refresh_notification/src/pull_to_refresh_notification.dart:287:12)
#3      PullToRefreshNotificationState._innerhandleScrollNotification (package:pull_to_refresh_notification/src/pull_to_refresh_notification.dart:205:9)
#4      PullToRefreshNotificationState._handleScrollNotification (package:pull_to_refresh_notification/src/pull_to_refresh_notification.dart:189:25)
#5      NotificationListener._dispatch (package:flutter/src/widgets/notification_listener.dart:129:41)
#6      Notification.visitAncestor (package:flutter/src/widgets/notification_listener.dart:47:20)
...
Handler: "onStart"
Recognizer: VerticalDragGestureRecognizer#395e6
  start behavior: start
════════════════════════════════════════════════════════════════════════════════════════════════════

我这样用的

PullToRefreshNotification(
          maxDragOffset: 80.0,
          armedDragUpCancel: false,
          onRefresh: () async {
            return await _purchaseRepository.refresh();
          },
          child: LoadingMoreCustomScrollView(

[Bug report] auto refresh

Version

3.0.1

Platforms

dart

Device Model

oppo android12

flutter info

[✓] Flutter (Channel stable, 3.7.12, on macOS 13.3.1 22E772610a darwin-x64,
    locale zh-Hans-CN)
    • Flutter version 3.7.12 on channel stable at /Users/gyt_lzm/dev/env/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4d9e56e694 (7 weeks ago), 2023-04-17 21:47:46 -0400
    • Engine revision 1a65d409c7
    • Dart version 2.19.6
    • DevTools version 2.20.1
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

How to reproduce?

use NestedScrollView . Automatically pull down and refresh every 15 seconds or so.

I don't do anything, it will automatically trigger a pull-down refresh at this frequency.

why?I sincerely need help, thank you!

Logs

No response

Example code (optional)

Scaffold(
        body: PullToRefreshNotification(
            key: refreshWidgetKey,//Setting or not setting this property has the same effect
            child: _buildNestedWidget(),
            onRefresh: _getAllData)
    )


 _buildNestedWidget() {
    return NestedScrollView(
      headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
        return <Widget>[
          PullToRefreshContainer(buildPulltoRefreshHeader),
          SliverAppBar(
            pinned: true,
            floating: true,
            centerTitle: false,
            ),..]});

Contact

[email protected]

Typo refreshWiget

class PullToRefreshScrollNotificationInfo {
  //...
  final Widget refreshWiget;
}

Delay pull back

Hey,
Currently the refresher pulls back immediately after returning true in the onRefresh function.
It would be nice to have a little delay to the pull back, so the user would be able to see the text longer after the refresh is done.
Maybe add a delayPullBack property that accepts a duration.
Thanks.

SDK

The argument type 'Widget Function(PullToRefreshScrollNotificationInfo)' can't be assigned to the parameter type 'Widget

如何设置下啦刷新,松手滚动到设置刷新的位置才出发刷新?

Content

PullToRefreshNotification(
        color: Colors.blue,
        onRefresh: () async {
          return Future.delayed(3000.milliseconds, () {
            return true;
          });
        },
        pullBackOnRefresh: false,
        maxDragOffset: double.infinity,
        refreshOffset: 40,
        // reachToRefreshOffset: 20,
        armedDragUpCancel: true,
        child:  ExtendedNestedScrollView(
			onlyOneScrollInBody: true,
        	controller: controller.scrollController,
			headerSliverBuilder:  (c, f) => [
				PullToRefreshContainer((info) {
                var offset = info?.dragOffset ?? 0.0;
                Widget child = Container(
                  alignment: Alignment.center,
                  height: offset,
                  // color: Colors.red,
                  width: double.infinity,
                  child: const CupertinoActivityIndicator(),
                );

                return SliverToBoxAdapter(
                  child: child,
                );
              }),
			],
			body: ListView.builder((c, i) => Text('$i'))
));

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.