Giter Site home page Giter Site logo

flutter_refresh's Introduction

flutter_refresh

A Flutter plugin for refreshing every scrollable view by pulling down-up.

Show cases

Roadmap

see:ROADMAP.md

Changelogs

see:CHANGELOG.md

Quick Start

Installation

1 Add

flutter_refresh : ^0.0.1

to your pubspec.yaml ,and run

flutter packages get 

in your project's root directory.

2 Add


import 'package:flutter_refresh/flutter_refresh.dart';

and write the code like this:



  Future<Null> onFooterRefresh() {
    return new Future.delayed(new Duration(seconds: 2), () {
      setState(() {
        _itemCount += 10;
      });
    });
  }

  
  Future<Null> onHeaderRefresh() {
    return new Future.delayed(new Duration(seconds: 2), () {
      setState(() {
        _itemCount = 10;
      });
    });
  }


  @override
  Widget build(BuildContext context) {
    ...
    return new Refresh(
          onFooterRefresh: onFooterRefresh,
          onHeaderRefresh: onHeaderRefresh,
          childBuilder: (BuildContext context,
              {ScrollController controller, ScrollPhysics physics}) {
            return new Container(
                child: new ListView.builder(
              physics: physics,
              controller: controller,
              itemBuilder: _itemBuilder,
              itemCount: _itemCount,
            ));
          },
        );
  }



full example see here: main.dart.

flutter_refresh's People

Contributors

jzoom avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

flutter_refresh's Issues

下拉刷新展示异常

如果布局既有listview也有左右滑动(子项SingleChildScrollView)左右滑动时会出现下拉刷新,我是在你的_drag(ScrollNotification)方法里加入了方向判断

语言切换

放开刷新的语言切换的api是什么呢,

刷新时顶部的下拉的距离没有回去

先上图:首先这个是默认的界面,刚初始化,还没刷新的
1
然后这个是刷新过后的,顶部多了个间距
2_
最后这个是我把它往上滑的,顶部那个距离,就多出现了那个刷新时间
3
然后上代码:
两种放child的使用方式我都用过:
1.
@OverRide
Widget build(BuildContext context) {
return Refresh(
controller: _refreshController,
onHeaderRefresh: () {
_loadData();
},
childBuilder: ( _ , {controller, physics}) => ListView.builder(
physics: physics,
controller: controller,
itemBuilder: ( _ , index) => _widgets[index],
itemCount: _widgets.length,
),
);
}
2.
@OverRide
Widget build(BuildContext context) {
return Refresh(
controller: _refreshController,
onHeaderRefresh: () {
_loadData();
},
child: ListView.builder(
itemBuilder: ( _ , index) => _widgets[index],
itemCount: _widgets.length,
),
);
}
我的布局大概是这样:
MaterialApp ->
appbar: AppBar
body:Scaffold ->
Refresh

进入内容页返回报错了

I/flutter (10831): Another exception was thrown: A ValueNotifier was used after being disposed.
I/flutter (10831): Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 4598 pos 14: 'oldChild == null || oldChild._debugLifecycleState == _ElementLifecycle.active': is not true.
I/chatty (10831): uid=10087(youliaowenzhou.net.news) Thread-4 identical 1 line
I/flutter (10831): Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 4598 pos 14: 'oldChild == null || oldChild._debugLifecycleState == _ElementLifecycle.active': is not true.
I/flutter (10831): Another exception was thrown: A ValueNotifier was used after being disposed.
I/flutter (10831): Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 2810 pos 12: '_debugLifecycleState == _ElementLifecycle.active
I/flutter (10831): Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 3775 pos 12: 'child == _child': is not true.
I/flutter (10831): Another exception was thrown: Duplicate GlobalKeys detected in widget tree.
I/flutter (10831): Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 4971 pos 12: '_children.contains(child)': is not true.
I/flutter (10831): Another exception was thrown: NoSuchMethodError: The getter 'userGestureInProgress' was called on null.
I/flutter (10831): Another exception was thrown: Duplicate GlobalKey detected in widget tree.
I/OMXClient(10831): IOmx service obtained

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.