pull_to_refresh 1.3.8

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 96

flutter_pulltorefresh #

Intro #

a widget provided to the flutter scroll component drop-down refresh and pull up load.support android and ios. If you are Chinese,click here(中文文档)

Features #

  • Android and iOS both supported
  • pull up and pull down
  • It's almost fit for all Scroll witgets,like GridView,ListView...
  • High extensibility,High degree of freedom
  • powerful Bouncing
  • support reverse ScrollView
  • provide more refreshStyle: Behind,Follow,UnFollow

ScreenShots #

Four RefreshStyle #

StyleFollowUnFollow
art
StyleBehindFront
art

Indicator #

StyleClassical(Follow,UnFollow)QQ WaterDrop
art
Styleflutter RefreshIndicatorWaterDropMaterial(Front)
art

How to use? #

the first way,use SmartRefresher and RefreshController


   dependencies:
     pull_to_refresh: ^1.3.8


RefreshController _refreshController;

initState(){

    super.initState();
    _refreshController = RefreshController();
    // if you need refreshing when init
   /*

     SchedulerBinding.instance.addPostFrameCallback((_) {
         _refreshController.requestRefresh();
        });

  */

}

void _onRefresh(){

   /*.  after the data return,
        use _refreshController.refreshComplete() or refreshFailed() to end refreshing
   */
}

void _onLoading(){
   /*
        use _refreshController.loadComplete() or loadNoData() to end loading
   */
}

build(){
...
SmartRefresher(
      enablePullDown: true,
      enablePullUp: true,
      header: defaultTargetPlatform == TargetPlatform.iOS?WaterDropHeader():WaterDropMaterialHeader(),
      controller: _refreshController,
      onRefresh: _onRefresh,
      onLoading: _onLoading,
      child: "yourContentScrollView",
    )
....
}

// don't forget to dispose refreshController
void dispose(){
    _refreshController.dispose();
    super.dispose();
}

Second Way(1.3.7 new),Considering that sometimes Sliver doesn't have to be placed in the first


     /*
           1. Request refresh operation
           For FrontStyle header, animateTo (0.0), for other refresh styles, animateTo (- trigger Distance) is the default trigger distance of 80.
           Of course, not all indicators have a trigger distance of 80, such as WaterDropHeader, which has an internal trigger distance of 100.0.
            _animateTo(-80.0);

            2.Request loading operation
            _scrollController
                         .animateTo(scrollController.position.maxScrollExtent);

            3.Sometimes, if you have to operate on the status of an internal indicator, you can use GlobalKey, which exposes getters and setters.
            GlobalKey<LoadIndicatorState> key = GlobalKey();
            key.currentState.mode = LoadStatus.idle;
      */

    /*
     for physics:
     1.for header: Follow,UnFollow,Behind Style
     return RefreshBouncePhysics()
     2.header is Front Style
     Return RefreshClampPhysics (springBackDistance: 100.0) when displayed, and 100.0 corresponds to the header's height
     Return to Clamping ScrollPhysics when hidden
    */
    CustomScrollView(
      controller: _scrollController,
      physics: RefreshBouncePhysics(), //don't forget,necessary
      slivers: [
        .....
        _enablePullDown?ClassicHeader.asSliver(onRefresh: () async {
          await Future.delayed(Duration(milliseconds: 1000));
          // return true,it mean refreshCompleted,return false it mean refreshFailed
          return true;
        }):null,
        .....
        _enablePullUp?ClassicFooter.asSliver(onLoading: () async {
          await Future.delayed(Duration(milliseconds: 1000));
          //return true it mean set the footerStatus to idle,else set to NoData state
          return true;
        }):null
      ].where((child) => child!=null).toList(),
    );

More #

Frequent problems #

  • <h3>IOS Status Bar Double-click Why ListView does not automatically scroll to the top?</h3> This problem is not my encapsulation error after testing. When the controller in ListView is replaced, this problem will occur, probably because of the processing operation in Scaffold.,please issue flutter。

  • <h3>How to use it with NestedScrollView?</h3> 1.3.0 provides a new attribute isNestWrapped for compatibility. Note that when this attribute is opened, scollController depends on NestScrollView, internally via PrimaryScrollController. of (context) To get scrollController, scrollController is placed in NestedScrollView。

  • <h3>Why is there a empty space in the top or tail indicator after using CuperNavigationBar (not just in this case)?</h3> the reason may be SafeArea,the solution: wrap SmartRefresher in SafeArea

  • <h3>Compatibility?</h3> 1.3.0 replaces a new method to implement the indicator. The internal indicator is implemented by monitoring scroll Controller position changes. There are no methods such as NotificationListener and GestureDector that may cause sliding gesture conflicts. So it should be compatible with most of the libraries that need to be used between gestures. However, some libraries may not be compatible and ScrollPhysics needs to be rewritten, which is clearly required for internal FrontStyle.

Thanks #

SmartRefreshLayout

LICENSE #

 
MIT License

Copyright (c) 2018 Jpeng

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

 

1.0.0 #

  • initRelease

1.0.1 #

  • Remove bottomColor

1.0.2 #

  • Add Failed RefreshMode when catch data failed
  • ReMake Default header and footer builder
  • Replace RefreshMode,loadMode to refreshing,loading
  • Replace onModeChange to onRefresh,onLoadMore

1.0.3 #

  • Fix error Props
  • Add interupt Scroll when failure status

1.0.4 #

  • Update README and demo

1.0.5 #

  • Remove headerHeight,footerHeight to get height inital
  • Make footer stay at the bottom of the world forever
  • replace idle to idel(my English mistake)
  • Fix defaultIndictor error Icon display

1.0.6 #

  • Use Material default LoadingBar
  • Add a bool paramter to onOffsetChange to know if pullup or pulldown
  • Fix Bug: when pulled up or pull-down, sizeAnimation and IOS elasticity conflict, resulting in beating.

1.0.7 #

  • Fix Bug1: The use of ListView as a container to cause a fatal error (continuous sliding) when the bottom control is reclaimed, using the SingleChildScrollView instead of preventing the base control from recovering many times from the exception
  • Fix Bug2: When the user continues to call at the same time in the two states of pull-down and drop down, the animation has no callback problem when it enters or fails.

1.0.8 #

  • Reproducing bottom indicator, no more manual drag to load more
  • Control property values change more,Mainly:1.onModeChange => onRefreshChange,onLoadChange, 2.Add enableAutoLoadMore,3.Remove bottomVisiableRange

1.1.0 #

Notice: This version of the code changes much, Api too

  • Transfer state changes to Wrapper of indicator to reduce unnecessary interface refresh.
  • No longer using Refreshmode or LoadMode,replaced int because the state is hard to determine.
  • Now support the ScrollView in the reverse mode
  • The indicators are divided into two categories, loadIndicator and refreshIndicator, and the two support header and footer
  • provided a controller to invoke some essential operations inside.
  • Move triggerDistance,completeTime such props to Config
  • Add ClassicIndicator Convenient construction indicator

1.1.1 #

  • Make triigerDistance be equally vaild for LoadWrapper
  • Add enableOverScroll attribute

1.1.2 #

  • Fix Bug:Refreshing the indicator requires multiple dragging to refresh
  • Fix ClassialIndicator syntax errors and display status when no data is added.

1.1.3 #

  • Fix contentList's item cannot be cached,Remove shrinkWrap,physics limit
  • Fix onOffsetChange callback error,In completion, failure, refresh state is also callback
  • Add unfollowIndicator implement in Demo(Example3)

1.1.4 #

  • Fix enableOverScroll does not work
  • Add default IndicatorBuilder when headerBuilder or footerBuilder is null
  • Fix cannot loading when user loosen gesture and listview enter the rebounding

1.1.5 #

  • Fix problem of offsetChange
  • Fix CustomScrollView didn't work
  • Fix refreshIcon not reference in ClassialIndicator

1.1.6 #

  • Fix Compile error after flutter update

1.2.0 #

  • Fixed the problem that ScrollController was not applied to internal controls
  • Optimize RefreshController
  • RefreshController changed to required now
  • Add feature:reuqestRefresh can jumpTo Bottom or Top
  • Fix problem: Refresh can still be triggered when ScrollView is nested internally
  • Remove rendered twice to get indicator height,replaced by using height attribute in Config
  • change RefreshStatus from int to enum

1.3.0 #

Total #

  • Support reverse ScrollView

  • Remove RefreshConfig,LoadConfig,Move to indicator setting

  • Add isNestWrapped to Compatible NestedScrollView

  • replace headerBuilder,footerBuilder attribute to header,footer

  • Separate header and footer operations:onRefresh and onLoading Callback,RefreshStatus is separated into RefreshStatus.LoadStatus

  • Fix Bug: twice loading (the footer state change before the ui update)

RefreshController #

  • Remove sendBack method,replaced by LoadComplete,RefreshComplete ,RefreshFailed,LoadNoData
  • Separate refresh and load operations
  • Add dispose method for Safety in some situation

Indicator #

  • Use another way to achieve drop-down refresh
  • Add drop-down refresh indicator style(Follow,UnFollow,Behind)
  • Add WaterDropIndicator,CustomIndicator
  • Make Custom Indicator easily

1.3.1 #

  • Add onClick CallBack for LoadIndicator
  • Fix enablepullUp or down invalid
  • Fix error Loading after 1.3.0 updated

1.3.2 #

  • Fix WaterDropHeader some attributes invalid
  • Fix enablePullUp and enablePullDown Dynamic set
  • implements auto hide FooterView when less than one page,no need to set enablePullUp to false
  • improve safety after disposed

1.3.3 #

  • Fixed the request Refresh problem: Sometimes it takes two times to be effective
  • Add child key support
  • Fix Bug:Pull-down triggers need to be pulled down more distances to trigger
  • Add resetNoData to resume footer state to idle

1.3.5 #

  • Add hideWhenNotFull bool to disable auto hide footer when data not enough one page
  • Add one new RefreshStyle:Front(just like RefreshIndicator)
  • Fix a bug: When the head overflows the view area, there is no clipping operation
  • Add material header(two indicator for FrontStyle)
  • Remove enableOverScroll

1.3.6 #

  • Fix NestedScrollView issue in 1.3.5
  • decrease default triggerDistance from 100.0 to 80.0
  • improve dragging scrolling speed of Front Style
  • Add offset attr in Front Style

1.3.7 #

  • Adding an asSlivers constructor can be inserted into slivers as a Sliver
  • Fix FrontStyle cannot support dynamic change enablePullDown
  • Fix FrontStyle cannot enter refresh state when init
  • Optimize indicator internal code to avoid locking widgets
  • Fix iOS click status cannot roll back without ScrollController in child
  • Fix one ignored situation after finish refresh -> completed(not in visual range)

1.3.8 #

  • Temporary fix deadly bug: PrimaryScrollController cannot shared by multiple Indicators

example/README.md

demo #

A new Flutter project.

Getting Started #

For help getting started with Flutter, view our online documentation.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  pull_to_refresh: ^1.3.8

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:pull_to_refresh/pull_to_refresh.dart';
  
Version Uploaded Documentation Archive
1.3.8 May 24, 2019 Go to the documentation of pull_to_refresh 1.3.8 Download pull_to_refresh 1.3.8 archive
1.3.7 May 24, 2019 Go to the documentation of pull_to_refresh 1.3.7 Download pull_to_refresh 1.3.7 archive
1.3.6 May 21, 2019 Go to the documentation of pull_to_refresh 1.3.6 Download pull_to_refresh 1.3.6 archive
1.3.5 May 20, 2019 Go to the documentation of pull_to_refresh 1.3.5 Download pull_to_refresh 1.3.5 archive
1.3.3 May 11, 2019 Go to the documentation of pull_to_refresh 1.3.3 Download pull_to_refresh 1.3.3 archive
1.3.2 May 8, 2019 Go to the documentation of pull_to_refresh 1.3.2 Download pull_to_refresh 1.3.2 archive
1.3.1 May 6, 2019 Go to the documentation of pull_to_refresh 1.3.1 Download pull_to_refresh 1.3.1 archive
1.3.0 May 6, 2019 Go to the documentation of pull_to_refresh 1.3.0 Download pull_to_refresh 1.3.0 archive
1.2.0 Mar 31, 2019 Go to the documentation of pull_to_refresh 1.2.0 Download pull_to_refresh 1.2.0 archive
1.1.6 Oct 25, 2018 Go to the documentation of pull_to_refresh 1.1.6 Download pull_to_refresh 1.1.6 archive

All 25 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
98
Health:
Code health derived from static analysis. [more]
92
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
96
Learn more about scoring.

We analyzed this package on May 24, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.3.1
  • pana: 0.12.16
  • Flutter: 1.5.4-hotfix.2

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/src/internals/indicator_wrap.dart. (-4.89 points)

Analysis of lib/src/internals/indicator_wrap.dart reported 10 hints, including:

line 105 col 19: The member 'activity' can only be used within instance members of subclasses of 'package:flutter/src/widgets/scroll_position.dart'.

line 105 col 19: The member 'activity' can only be used within 'package:flutter/src/widgets/scroll_position.dart' or a test.

line 106 col 19: The member 'activity' can only be used within instance members of subclasses of 'package:flutter/src/widgets/scroll_position.dart'.

line 106 col 19: The member 'activity' can only be used within 'package:flutter/src/widgets/scroll_position.dart' or a test.

line 107 col 19: The member 'activity' can only be used within instance members of subclasses of 'package:flutter/src/widgets/scroll_position.dart'.

Fix lib/src/internals/refresh_physics.dart. (-1.99 points)

Analysis of lib/src/internals/refresh_physics.dart reported 4 hints:

line 183 col 26: The member 'activity' can only be used within instance members of subclasses of 'package:flutter/src/widgets/scroll_position.dart'.

line 183 col 26: The member 'activity' can only be used within 'package:flutter/src/widgets/scroll_position.dart' or a test.

line 189 col 26: The member 'activity' can only be used within instance members of subclasses of 'package:flutter/src/widgets/scroll_position.dart'.

line 189 col 26: The member 'activity' can only be used within 'package:flutter/src/widgets/scroll_position.dart' or a test.

Fix lib/src/indicator/material_indicator.dart. (-0.50 points)

Analysis of lib/src/indicator/material_indicator.dart reported 1 hint:

line 218 col 23: Name non-constant identifiers using lowerCamelCase.

Fix additional 5 files with analysis or formatting issues. (-1 points)

Additional issues in the following files:

  • lib/src/internals/default_constants.dart (1 hint)
  • lib/src/smart_refresher.dart (1 hint)
  • lib/pull_to_refresh.dart (Run flutter format to format lib/pull_to_refresh.dart.)
  • lib/src/indicator/custom_indicator.dart (Run flutter format to format lib/src/indicator/custom_indicator.dart.)
  • lib/src/internals/slivers.dart (Run flutter format to format lib/src/internals/slivers.dart.)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test