pull_to_refresh 1.1.6

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

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(中文文档)

(Suspend maintenance until 12 months after the end of the postgraduate entrance examination.)

Features

  • Android and iOS both spported
  • pull up and pull down
  • It's almost fit for all witgets,like GridView,ListView,Container...
  • High extensibility,High degree of freedom
  • powerful Bouncing

Screenshots

<br>

How to use?

1.the first declare following in your pubspec.yml


   dependencies:
     pull_to_refresh: ^1.1.6
     

2.and then,import that line,SmartRefresher is a component that is wrapped outside your content View



   import "package:pull_to_refresh/pull_to_refresh.dart";
   ....
   
   build() =>
   
    new SmartRefresher(
        enablePullDown: true,
        enablePullUp: true,
        onRefresh: _onRefresh,
        onOffsetChange: _onOffsetCallback,
        child: new ListView.builder(

                           itemExtent: 40.0,
                           itemCount: data.length,
                           itemBuilder: (context,index){
                             return data[index];
                           },

                         )
    )

3.You should set the indicator according to the different refresh mode.build footer is the same with that. Of course, I have built an indicator convenient to use, called ClassicIndicator. If I do not meet the requirements, I can choose to define an indicator myself.



  Widget _buildHeader(context,mode){
   return new ClassicIndicator(mode: mode);
  }
  
 
  Widget _buildFooter(context,mode){
    // the same with header
    ....
  }

  new SmartRefresher(
     ....
     footerBuilder: _buildFooter,
     headerBuilder: _buildHeader
  )


Whether at the top or bottom, the onRefresh will be callback when the indicator state is refreshed. But how can I tell the result to SmartRefresher? It's very simple. It provides a RefreshController inside, you can pass the construction of a controller to SmartRefresher, and then call.SendBack (int status) can change the state of success or failure.


    void _onRefresh(bool up){
		if(up){
		   //headerIndicator callback
		   new Future.delayed(const Duration(milliseconds: 2009))
                               .then((val) {
                                 _refreshController.sendBack(true, RefreshStatus.failed);
                           });
		   
		}
		else{
			//footerIndicator Callback
		}
    }

  

Props Table

SmartRefresher:

Attribute NameAttribute ExplainParameter TypeDefault Valuerequirement
childyour content View? extends ScrollViewnullnecessary
headerBuilderthe header indictor(BuildContext,int) => Widgetnullif enablePullDown is necessary,else option
footerBuilderthe footer indictor(BuildContext,int) => Widgetnullif enablePullUp is necessary,else option
enablePullDownswitch of the pull downbooleantrueoptional
enablePullUpswitch of the pull upbooleanfalseoptional
onRefreshwill callback when the one indicator is getting refreshing(bool) => Voidnulloptional
onOffsetChangecallback while you dragging and outOfrange(bool,double) => Voidnulloptional
controllercontroll inner some statesRefreshControllernulloptional
headerConfigThis setting will affect which type of indicator you use and config contains a lot props,such as triigerDistance,completedurtion...ConfigRefreshConfigoptional
footerConfigThis setting will affect which type of indicator you use and config contains a lot props,such as triigerDistance,completedurtion...ConfigLoadConfigoptional
enableOverScrollthe switch of Overscroll,When you use RefreshIndicator(Material), you may have to shut down.booltrueoptional

RefreshConfig:

Attribute NameAttribute ExplainDefault Value
triggerDistanceDrag distance to trigger refresh100.0
completeDurationStay in time when you return to success and failure800
visibleRangeThe scope of the indicator can be seen(refresh state)50.0

LoadConfig:

Attribute NameAttribute ExplainDefault Value
triggerDistanceDrag distance to trigger loading5.0
autoLoadenable open Auto Load,If false triggerDistance is invalidtrue
bottomWhenBuildIs it at the bottom of listView when it is loaded(When your header is LoadConfig)true

FAQ

  • <h3>Does it support simple RefreshIndicator (material) + pull up loading and no elastic refresh combination?<br></h3> Yes, as long as you set the node properties enableOverScroll = false, enablePullDown = false, it's OK to wrap a single RefreshIndicator outside, and Example4 has given an example in demo.

  • <h3>Does it support an indicator that does not follow the list?<br></h3> This I did not package in the library, because even if I encapsulated, it would only make the logic complexity of the code increased, so you need yourself to use the onOffsetChange callback method to implement it. It is not difficult to use Stack to encapsulate it. It can refer to the idea of Example3 or my project flutter_gank.

  • <h3>Why does child attribute extend from original widget to scrollView?<br></h3> Because of my negligence, I didn't take into account the problem that child needed to cache the item, so the 1.1.3 version had corrected the problem of not caching.

  • <h3>What impact does this library have on performance?<br></h3> No, although I did not actually use data to test performance problems, I did not appear to pull up or pull down the sliding carton situation in the process of another project development.

  • <h3>Is there any way to achieve the maximum distance to limit springback?<br></h3> The answer is negative. I know that it must be done by modifying the ScrollPhysics, but I am not quite sure about the Api in it, but I failed. If you have a way to solve this problem, please come to a PR

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

example/lib/main.dart

import 'ui/MainActivity.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(

      title: 'Pulltorefresh Demo',
      debugShowCheckedModeBanner:   false,
      theme: new ThemeData(
        // This is the theme of your application.
        //s
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or press Run > Flutter Hot Reload in IntelliJ). Notice that the
        // counter didn't reset back to zero; the application is not restarted.
        primarySwatch: Colors.blue,
      ),
      home: new MainActivity(title: 'Pulltorefresh'),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  pull_to_refresh: ^1.1.6

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages 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.1.6 Oct 25, 2018 Go to the documentation of pull_to_refresh 1.1.6 Download pull_to_refresh 1.1.6 archive
1.1.5 Jun 26, 2018 Go to the documentation of pull_to_refresh 1.1.5 Download pull_to_refresh 1.1.5 archive
1.1.4 Jun 2, 2018 Go to the documentation of pull_to_refresh 1.1.4 Download pull_to_refresh 1.1.4 archive
1.1.3 May 29, 2018 Go to the documentation of pull_to_refresh 1.1.3 Download pull_to_refresh 1.1.3 archive
1.1.2 May 23, 2018 Go to the documentation of pull_to_refresh 1.1.2 Download pull_to_refresh 1.1.2 archive
1.1.1 May 21, 2018 Go to the documentation of pull_to_refresh 1.1.1 Download pull_to_refresh 1.1.1 archive
1.1.0 May 18, 2018 Go to the documentation of pull_to_refresh 1.1.0 Download pull_to_refresh 1.1.0 archive
1.0.8 May 12, 2018 Go to the documentation of pull_to_refresh 1.0.8 Download pull_to_refresh 1.0.8 archive
1.0.7 May 11, 2018 Go to the documentation of pull_to_refresh 1.0.7 Download pull_to_refresh 1.0.7 archive
1.0.6 May 10, 2018 Go to the documentation of pull_to_refresh 1.0.6 Download pull_to_refresh 1.0.6 archive

All 16 versions...

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

We analyzed this package on Oct 26, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0-dev.7.1.flutter-b99bcfd309
  • pana: 0.12.5
  • Flutter: 0.10.1

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/src/smart_refresher.dart. (-1 points)

Analysis of lib/src/smart_refresher.dart reported 2 hints:

line 86 col 8: The value of the field '_isDragging' isn't used.

line 333 col 36: The member 'buildSlivers' can only be used within instance members of subclasses of 'package:flutter/src/widgets/scroll_view.dart'.

Format lib/pull_to_refresh.dart.

Run flutter format to format lib/pull_to_refresh.dart.

Format lib/src/indicator/classic_indicator.dart.

Run flutter format to format lib/src/indicator/classic_indicator.dart.

Fix additional 3 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/internals/default_constants.dart (Run flutter format to format lib/src/internals/default_constants.dart.)
  • lib/src/internals/indicator_config.dart (Run flutter format to format lib/src/internals/indicator_config.dart.)
  • lib/src/internals/refresh_physics.dart (Run flutter format to format lib/src/internals/refresh_physics.dart.)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test