pull_to_refresh 1.1.0

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

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(中文文档) (Still in the development stage, the function is not perfect)

Features

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

Screenshots

<br> 1.1.0(support reverse ScrollView) <br>

How to use?

1.the first declare following in your pubspec.yml


   dependencies:
     pull_to_refresh: ^1.1.0
     

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 Container(
          color: Colors.white,
          child: new ListView.builder(
            physics: const NeverScrollableScrollPhysics(),
            shrinkWrap: true,
            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
		}
    }

  

5.If your content view is a rolling component, such as ScrollView, ListView, GridView and so on, you assign these two attributes to the component.Because my parts are used in the ListView nested package, this is very important,if you don't notice it,you will get some problems.


new ListView(){
    physics: const NeverScrollableScrollPhysics(),
    shrinkWrap: true,
    child:...
}

Props Table

SmartRefresher:

Attribute NameAttribute ExplainParameter TypeDefault Valuerequirement
childyour content ViewWidgetnullnecessary
headerBuilderthe header indictor(BuildContext,int) => Widgetnulloptional
footerBuilderthe footer indictor(BuildContext,int) => Widgetnulloptional
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(In addition to refreshing state and completing,failed state),range: 0~realDistance/triggerDistance(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

Attention point

1.The component is unbounded, so when you use it, be careful about the problems caused by the height, especially the column, stack, which is also a control of unrestricted height, to be extra careful.

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

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.0"

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.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
1.0.5 May 8, 2018 Go to the documentation of pull_to_refresh 1.0.5 Download pull_to_refresh 1.0.5 archive
1.0.4 May 7, 2018 Go to the documentation of pull_to_refresh 1.0.4 Download pull_to_refresh 1.0.4 archive
1.0.3 May 4, 2018 Go to the documentation of pull_to_refresh 1.0.3 Download pull_to_refresh 1.0.3 archive
1.0.2 May 4, 2018 Go to the documentation of pull_to_refresh 1.0.2 Download pull_to_refresh 1.0.2 archive
1.0.1 May 4, 2018 Go to the documentation of pull_to_refresh 1.0.1 Download pull_to_refresh 1.0.1 archive
1.0.0 May 4, 2018 Go to the documentation of pull_to_refresh 1.0.0 Download pull_to_refresh 1.0.0 archive

Analysis

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

  • Dart: 2.0.0-dev.54.0
  • pana: 0.10.6
  • Flutter: 0.4.4

Scores

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

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Suggestions

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 7 hints.

    Run flutter format to format lib/pull_to_refresh.dart.

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

    Similar analysis of the following files failed:

    • lib/src/internals/default_constants.dart (hint)
    • lib/src/internals/indicator_config.dart (hint)
    • lib/src/internals/indicator_wrap.dart (hint)
    • lib/src/smart_refresher.dart (hint)

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.6 1.14.9
meta 1.1.5
sky_engine 0.0.99
typed_data 1.1.5
vector_math 2.0.6 2.0.7
Dev dependencies
flutter_test