flutter_easyrefresh 1.2.7

flutter_easyrefresh #

License Awesome Flutter Pub

English | 中文

正如名字一样,EasyRefresh很容易就能在Flutter应用上实现下拉刷新以及上拉加载操作,它支持几乎所有的Flutter控件,但前提是需要包裹成ScrollView。它的功能与Android的SmartRefreshLayout很相似,同样也吸取了很多三方库的优点。EasyRefresh中集成了多种风格的Header和Footer,但是它并没有局限性,你可以很轻松的自定义。使用Flutter强大的动画,甚至随便一个简单的控件也可以完成。EasyRefresh的目标是为Flutter打造一个强大,稳定,成熟的下拉刷新框架。

特点功能: #

  • 支持Andorid(光晕),ios(越界回弹)效果
  • 支持绝大多数Widget
  • 支持自定义并且已经集成了很多炫酷的 Header 和 Footer
  • 支持下拉刷新、上拉加载(可自动)
  • 支持 Header 和 Footer 列表嵌入以及视图浮动两种形式
  • 支持列表事件监听,制作任何样子的 Header 和 Footer,并且能够放在任何位置
  • 支持首次刷新,并自定义视图
  • 支持自定义列表为空时的视图,仅限于ScrollView

传送门 #

Demo #

下载 APK-Demo

项目演示 #

基本样式自动加载
BasicPageAutoLoadPage
浮动效果个人中心
FloatPageUserProfilePage
CustomScroolViewSwiper
SliverPageSwiperPage
列表嵌入Cupertino
ListEmbedPageCupertinoPage

样式演示 #

MaterialBallPulse
MaterialPageBallPulsePage
BezierCircleBezierHourGlass
BezierCirclePageBezierHourGlassPage
PhoenixDelivery
PhoenixPageTaurusPage
SpaceDelivery
SpacePageDeliveryPage

简单用例 #

1.在 pubspec.yaml 中添加依赖 #

//pub方式
dependencies:
  flutter_easyrefresh: ^1.2.7

//导入方式
dependencies:
  flutter_easyrefresh:
    path: 项目路径

2.在布局文件中添加 EasyreFresh #

import 'package:flutter_easyrefresh/easy_refresh.dart';
....
  GlobalKey<EasyRefreshState> _easyRefreshKey = new GlobalKey<EasyRefreshState>();
....
  new EasyRefresh(
    key: _easyRefreshKey,
    child: ScrollView(),
    onRefresh: () async{
      ....
    },
    loadMore: () async {
      ....
    },
  )

3.触发刷新和加载动作 #

  // 如果不需要可以不用设置EasyRefresh的key
  _easyRefreshKey.currentState.callRefresh();
  _easyRefreshKey.currentState.callLoadMore();
import 'package:flutter_easyrefresh/easy_refresh.dart';
....
  GlobalKey<RefreshHeaderState> _headerKey = new GlobalKey<RefreshHeaderState>();
  GlobalKey<RefreshFooterState> _footerKey = new GlobalKey<RefreshFooterState>();
....
  // 因为EasyRefresh会对Header和Footer进行更新,为了与用户保持统一的操作状态,必须设置key
  // 不同的Header和Footer可能有不同的参数设置
  new EasyRefresh(
    refreshHeader: MaterialHeader(
        key: _headerKey,
    ),
    refreshFooter: MaterialFooter(
        key: _footerKey,
    ),
    child: ScrollView(),
    ....
  )

捐赠 #

如果你喜欢我的项目,请在项目右上角 "Star" 一下。你的支持是我最大的鼓励! ^_^ 你也还可以扫描下面的二维码,或者通过Donate to this project using Paypal,对作者进行打赏。

如果在捐赠留言中备注名称,将会被记录到列表中~ 如果你也是github开源作者,捐赠时可以留下github项目地址或者个人主页地址,链接将会被添加到列表中起到互相推广的作用
捐赠列表

QQ讨论群 - 554981921 #

进群须知 #

这个群不仅仅是解决EasyreFresh的问题,任何Flutter相关的问题都可以进行讨论。正如它的名字一样,有问必答,只要群主有时间,都会帮大家一起解决问题。

感谢 #

PullToRefresh_Flutter
flutter_pulltorefresh
SmartRefreshLayout
flutter_spinkit

开源协议 #

 
MIT License

Copyright (c) 2018 xuelongqy

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.

 

Change log #

V 1.0.0 #

Add: Drop-down refresh and pull-up loading
Add: Rebound effect and halo effect
Add: Custom Headers and Footers
Add: Material and BallPulse style

V 1.0.1 #

Adjustment: Height of trigger loading
Add: BezierCircleHeader
Add: BezierHourGlassHeader
Add: BezierBounceFooter

V 1.0.2 #

Adjustment: Drag coefficient of pull-up loading
Fix: Problem of multiple pull-ups that may get stuck
Fix: Automatic triggering BallPulse without animation problems

V 1.0.3 #

Fix: Using CustomScrollView load error
Fix: Partial view than SafeArea deviation
Add: CustomScrollView usage examples

V 1.0.4 #

Modify: UserProfilePage
Add: limitScroll attribute (scrollable list during refresh or loading)

V 1.0.5 #

Fix: Not setting onRefresh causes more problems without triggering load

V 1.0.6 #

Add: RefreshSafeArea,resolved Sliding Conflict

V 1.0.7 #

Fix: loadMore conflicts with autoLoad
Fix: Drag a list repeatedly triggers a cross-border event

V 1.0.8 #

Add: Header and Footer listeners for quick and easy customization
Add: Header and Footer connectors for placing Header and Footer in any position
Add:Manual control load refresh finish
Fix: Trigger loading problem across borders
Fix: BallPulse animation problem
Fix: Exception when the refresh process exited
Add: ClassicHeader and ClassicFooter animation
Fix: Manually calling refresh or loading does not trigger callbacks

V 1.0.9 #

Fix: Classic style arrow reverse

V 1.1.0 #

Fix: Classic style arrows don't recover
Add: Cupertino style example

V 1.1.1 #

Fix: Pulling down too fast triggers scrolling up and causing slow rebound
Add: Taurus and Phoenix style

V 1.1.2 #

Add: Flare animation - Space
Add: Delivery animation

V 1.1.3 #

Fix: ios repeatedly pull down, the distance becomes longer
Modify: Delivery animation height

V 1.1.4 #

Fix: HeaderListener and FooterListener use both highly updated fusions
Adjustment: Delivery animation speed
Add: Close callback for Header and Footer
Add: First refresh
Add: Empty widget

V 1.1.5 #

Fix: Pull down may get stuck

V 1.1.6 #

Fix: BallPulse sometimes bounces
Fix:Footer float when the pullback list follows the move
Fix:Switch direction when Header floats, list moves slightly
Adjustment: MaterialFooter animation
Fix: callRefresh error

V 1.1.7 #

Fix: Pullback control causes the list to slow down
Modify: Child to Widget type
Adjustment:ClassicsHeader style

V 1.1.9 #

Fix: Pullback exception when loadMore or onRefresh is not set

V 1.2.0 #

Fix: onNoMore callback is not accurate
Add: isRefreshing to determine if it is being refreshed or loaded
Add: Header and Footer status change callbacks
Add: Header and Footer height change callbacks

V 1.2.1 #

Specification code to improve compatibility
Adjustment: part of the style
The library does not have its own space style, transfer to example

V 1.2.2 #

Fix: header is null, onRefresh is not null error #19

V 1.2.3 #

Add: rebound effect when onRefresh and loadMore are null #18

V 1.2.4 #

Add: support for NestedScrollView #7,#11

V 1.2.5 #

Fix: CustomScrollView does not maintain semanticChildCount error #24,#25
Fix: CustomScrollView refresh or load causes emptyWidget to be added multiple times, thanks to hwh97 #29

V 1.2.6 #

Fix: NotificationListener is invalid #30
Remove: A certain height is reached to trigger a refresh or load
Fix: Unable to modify prompt text after refresh or loading #22

V 1.2.7 #

Add: builder property to add additional components, such as scroll bars #39
Add: Scrollbar example
Add: Taobao second floor example #26

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      // App名字
      title: 'EasyRefresh',
      // App主题
      theme: new ThemeData(
        primarySwatch: Colors.orange,
      ),
      // 主页
      home: BasicPage(),
    );
  }
}

class BasicPage extends StatefulWidget {
  @override
  _BasicPageState createState() => _BasicPageState();
}

class _BasicPageState extends State<BasicPage> {
  List<String> addStr = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"];
  List<String> str = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"];
  GlobalKey<EasyRefreshState> _easyRefreshKey =
      new GlobalKey<EasyRefreshState>();
  GlobalKey<RefreshHeaderState> _headerKey =
      new GlobalKey<RefreshHeaderState>();
  GlobalKey<RefreshFooterState> _footerKey =
      new GlobalKey<RefreshFooterState>();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("EasyRefresh"),
      ),
      body: Center(
          child: new EasyRefresh(
        key: _easyRefreshKey,
        behavior: ScrollOverBehavior(),
        refreshHeader: ClassicsHeader(
          key: _headerKey,
          bgColor: Colors.transparent,
          textColor: Colors.black87,
          moreInfoColor: Colors.black54,
          showMore: true,
        ),
        refreshFooter: ClassicsFooter(
          key: _footerKey,
          bgColor: Colors.transparent,
          textColor: Colors.black87,
          moreInfoColor: Colors.black54,
          showMore: true,
        ),
        child: new ListView.builder(
            //ListView的Item
            itemCount: str.length,
            itemBuilder: (BuildContext context, int index) {
              return new Container(
                  height: 70.0,
                  child: Card(
                    child: new Center(
                      child: new Text(
                        str[index],
                        style: new TextStyle(fontSize: 18.0),
                      ),
                    ),
                  ));
            }),
        onRefresh: () async {
          await new Future.delayed(const Duration(seconds: 1), () {
            setState(() {
              str.clear();
              str.addAll(addStr);
            });
          });
        },
        loadMore: () async {
          await new Future.delayed(const Duration(seconds: 1), () {
            if (str.length < 20) {
              setState(() {
                str.addAll(addStr);
              });
            }
          });
        },
      )),
      persistentFooterButtons: <Widget>[
        FlatButton(
            onPressed: () {
              _easyRefreshKey.currentState.callRefresh();
            },
            child: Text("refresh", style: TextStyle(color: Colors.black))),
        FlatButton(
            onPressed: () {
              _easyRefreshKey.currentState.callLoadMore();
            },
            child: Text("loadMore", style: TextStyle(color: Colors.black)))
      ], // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_easyrefresh: ^1.2.7

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:flutter_easyrefresh/ball_pulse_footer.dart';
import 'package:flutter_easyrefresh/ball_pulse_header.dart';
import 'package:flutter_easyrefresh/bezier_bounce_footer.dart';
import 'package:flutter_easyrefresh/bezier_circle_header.dart';
import 'package:flutter_easyrefresh/bezier_hour_glass_header.dart';
import 'package:flutter_easyrefresh/delivery_header.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_easyrefresh/material_footer.dart';
import 'package:flutter_easyrefresh/material_header.dart';
import 'package:flutter_easyrefresh/phoenix_footer.dart';
import 'package:flutter_easyrefresh/phoenix_header.dart';
import 'package:flutter_easyrefresh/taurus_footer.dart';
import 'package:flutter_easyrefresh/taurus_header.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
96
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
98
Learn more about scoring.

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

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
cupertino_icons ^0.1.2 0.1.2
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

Admin