zeking_refresh 0.0.11

  • Readme
  • Changelog
  • Example
  • Installing
  • 62

[TOC]

zeking_refresh #

一个支持刷新加载中,刷新失败,刷新空数据,加载更多加载中,加载更多失败,加载更多加载全部数据,业务loading的刷新组件

1. 快速使用 #

1. 依赖 #

dependencies:
  zeking_refresh: ^0.0.8

2. 安装 #

flutter packages get

3. 引用 #

import 'package:zeking_refresh/zeking_refresh.dart';

4. 简单使用 #

  ZekingRefreshController _refreshController;

  @override
  void initState() {
    _refreshController = ZekingRefreshController();
    super.initState();

    /// 首次进去 加载数据 ,会自动调用 onRefresh 方法
    _refreshController.refreshingWithLoadingView();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ZekingRefresh(
        controller: _refreshController,  // 必须参数
        onRefresh: onRefresh,
        onLoading: onLoading,
        child: ListView.builder(
          padding: EdgeInsets.all(0),
          itemBuilder: (BuildContext context, int index) {
            return ItemWidget(data[index], () {});
          },
          itemCount: data.length,
        ),
      ),
    );
  }

2. ZekingRefreshController #

通过 ZekingRefreshController 的方法来进行不同场景的UI展示

方法说明
refreshingWithLoadingView()刷新:打开一个新的页面,首先有一个圈圈在中间转,同时请求数据 widget
refreshFaild({String uiMsg, String toastMsg})刷新:数据为空 widget
refreshEmpty({String uiMsg, String toastMsg})刷新:失败 widget
refreshSuccess({String toastMsg})刷新:成功,修改状态,显示结果
loadMoreFailed({String uiMsg, String toastMsg})加载更多:失败 widget
loadMoreNoMore({String uiMsg, String toastMsg})加载更多:已加载全部数据widget
loadMoreSuccess({String toastMsg})加载更多:成功,修改状态,
loading()业务加载中:loading widget ( 业务加载中:比如,上传图片,登录,提交数据的loading widget )
loadingEnd({String toastMsg})业务加载中: 结束 loading widget 的展示

说明一下:在上面的方法中,有的方法有uiMsgtoastMsg参数,是干什么的呢?

uiMsg 是用来动态修改 场景Ui上面的提示语的, 但是这个只对使用了框架默认的UI 才会起作用,若是自定义的 widget,需要在外部自己去setState

toastMsg 是用来谈吐司提示的,默认已经实现了 toast ,当然你不满足于默认的吐司样式, 可以自己去定义,也可以弹一个dialog,或者打印一个log,到时候传一个方法给我就好了, 具体的看ZekingRefreshtoastMethod参数,下面

3. ZekingRefresh #

这个就是我们的刷新控件了,

ZekingRefresh({
        @required this.controller,
        @required this.onRefresh,
                  this.onLoading,
                  this.child,
                  this.displacement,
                  this.canLoadMore = true,
                  this.canRefresh = true,
                  this.scrollController,
                  this.physics,
                  this.useScrollController = true,
                  this.refreshLoadingWidget,
                  this.refreshLoadingImagePath,
                  this.refreshEmptyWidget,
                  this.refreshEmptyMessage,
                  this.refreshEmptyImagePath,
                  this.refreshEmptyImageWidth,
                  this.refreshEmptyImageHeight,
                  this.refreshEmptyCenterPadding,
                  this.refreshFailWidget,
                  this.refreshFailMessage,
                  this.refreshFailImagePath,
                  this.refreshFailImageWidth,
                  this.refreshFailImageHeight,
                  this.refreshFailCenterPadding,
                  this.loadLoadingWidget,
                  this.loadLoadingMessage,
                  this.loadFailWidget,
                  this.loadFailMessage,
                  this.loadNoMoreWidget,
                  this.loadNoMoreMessage,
                  this.loadingWidget,
                  this.toastMethod
              });
参数说明
controller其实就是 ZekingRefreshController 用来控制不同场景的切换
onRefresh刷新方法
onLoading加载更多方法
child只有支持了加载更多,最后才会转为CustomScrollview,剩下的不会
displacement下拉刷新圈圈的偏移量,默认是40
canLoadMore是否支持加载更多,默认 true
canRefresh是否支持 下拉刷新,默认 true
useScrollController是否给默认的ScrollController ,默认 true
scrollController当useScrollController为true,ScrollController也为null的话,会new 一个 useScrollController
physicsScrollPhysics
============================================
refreshLoadingWidget自定义的 刷新 加载中 widget
refreshLoadingImagePath设置框架 默认 的 刷新 加载中 widget的图片路径,会自动旋转 ,refreshLoadingWidget 和 refreshLoadingImagePath 都不设置的话,默认显示一个CircularProgressIndicator
============================================
refreshEmptyWidget自定义的 刷新 空数据 的 widget
refreshEmptyMessage设置框架 默认 刷新 空数据 widget 的 提示语 ( 默认为 : '暂无数据,请点击屏幕重试' )
refreshEmptyImagePath设置框架 默认 刷新 空数据 widget 的 图片路径,(图片和提示语的位置是居中,图片在上,提示语在下)
refreshEmptyImageWidth设置框架 默认 刷新 空数据 widget 的 图片 宽度 ,( 默认 136 )
refreshEmptyImageHeight设置框架 默认 刷新 空数据 widget 的 图片 高度 , ( 默认 122 )
refreshEmptyCenterPadding设置框架 默认 刷新 空数据 widget 的 图片 和 提示语 的间隔,( 默认 36 )
============================================
refreshFailWidget自定义的 刷新 失败 widget
refreshFailMessage设置框架 默认 刷新 失败 widget 的 提示语 ( 默认为 : '加载失败,请点击屏幕重试' )
refreshFailImagePath设置框架 默认 刷新 失败 widget 的 图片路径 ,(图片和提示语的位置是居中,图片在上,提示语在下)
refreshFailImageWidth设置框架 默认 刷新 失败 widget 的 图片 宽度 ,( 默认 136 )
refreshFailImageHeight设置框架 默认 刷新 失败 widget 的 图片 高度 , ( 默认 122 )
refreshFailCenterPadding设置框架 默认 刷新 失败 widget 的 图片 和 提示语 的间隔,( 默认 36 )
============================================
loadLoadingWidget自定义的 加载更多 加载中 widget
loadLoadingMessage设置框架 默认 的 加载更多 加载中 widget的提示语( 默认为: '正在加载更多数据' )
============================================
loadFailWidget自定义的 加载更多 失败 widget
loadFailMessage设置框架 默认 的 加载更多 失败 widget的提示语( 默认为: '加载失败,请点击重试' )
============================================
loadNoMoreWidget自定义的 加载更多 已加载全部数据 widget
loadNoMoreMessage设置框架 默认 的 加载更多 已加载全部数据 widget的提示语( 默认为: '已加载全部数据' )
============================================
loadingWidget自定义的 业务加载中 widget (业务加载中:比如,上传图片,登录,提交数据的loading widge)
============================================
toastMethod自定义的 弹吐司方法,

ChangeLog #

0.0.11 #

修复0.0.10不完善的bug

0.0.10 #

修复与NestedScrollView配合的时候,加载更多存在的问题

0.0.9 #

将 业务逻辑 状态 Loading 和 LoadingEnd  单独抽取出来,防止和loadmore 相关状态之间存在冲突,倒是页面显示异常

0.0.8 #

修复当canLoadMore为false,canRefresh为true的时候,
child为CustomScrollview,在IOS上面的滚动bug。

0.0.7 #

1. onRefresh 属性不再是必填项目,根据canRefresh做判断
2. 更改最后的控件生成逻辑,只有canLoadMore为true的时候,
   最后控件才会转为CustomScrollview。不然你写的是什么widget
   就是什么widget,不做改变。
3. 这次修改以后,业务loading widget 得到了更广泛的应用,
   不管你的页面是否需要下拉刷新,上啦加载更多,只要你的页面需要
   使用到业务loading 这样的布局,就可以直接使用zeking_refresh

0.0.6 #

修复多次调用onLoading方法的bug

0.0.5 #

更新文档说明,修复和NestedScrollView一起使用的时候的bug

0.0.4 #

更新文档说明

0.0.3 #

修复小问题

0.0.2 #

解决引用之后 项目跑不起来的bug

0.0.1 #

初始化上传

example/README.md

zeking_refresh_example #

Demonstrates how to use the zeking_refresh plugin.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

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


dependencies:
  zeking_refresh: ^0.0.11

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:zeking_refresh/zeking_refresh.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
38
Health:
Code health derived from static analysis. [more]
97
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
62
Learn more about scoring.

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

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/src/utils/toast.dart. (-2.48 points)

Analysis of lib/src/utils/toast.dart reported 5 hints:

line 8 col 20: Name non-constant identifiers using lowerCamelCase.

line 9 col 20: Name non-constant identifiers using lowerCamelCase.

line 10 col 20: Name non-constant identifiers using lowerCamelCase.

line 11 col 20: Name non-constant identifiers using lowerCamelCase.

line 12 col 20: Name non-constant identifiers using lowerCamelCase.

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

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

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

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

Format lib/src/utils/zeking_toast_util.dart.

Run flutter format to format lib/src/utils/zeking_toast_util.dart.

Fix additional 7 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/zeking_load_fail_widget.dart (Run flutter format to format lib/src/zeking_load_fail_widget.dart.)
  • lib/src/zeking_load_loading_widget.dart (Run flutter format to format lib/src/zeking_load_loading_widget.dart.)
  • lib/src/zeking_load_no_more_widget.dart (Run flutter format to format lib/src/zeking_load_no_more_widget.dart.)
  • lib/src/zeking_refresh_indicator.dart (Run flutter format to format lib/src/zeking_refresh_indicator.dart.)
  • lib/src/zeking_refresh_loading_view.dart (Run flutter format to format lib/src/zeking_refresh_loading_view.dart.)
  • lib/src/zeking_refresh_physics.dart (Run flutter format to format lib/src/zeking_refresh_physics.dart.)
  • lib/zeking_refresh.dart (Run flutter format to format lib/zeking_refresh.dart.)

Maintenance issues and suggestions

The description contains too many non-ASCII characters. (-20 points)

The site uses English as its primary language. The value of the description field in your package's pubspec.yaml field should primarily contain characters used in English.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

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 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test