refresher 1.0.1+1

  • Readme
  • Changelog
  • Example
  • Installing
  • 71

Refresher #

My custom Pull to Refresh Widget, mimicking iOS Pull to Refresh except for the toolbar

Installation #

First, add refresher as a dependency in your pubspec.yaml file.

refresher: ^0.0.4+2

Example #

class RefresherDemo extends StatefulWidget {
  @override
  _RefresherDemoState createState() => _RefresherDemoState();
}

class _RefresherDemoState extends State<RefresherDemo> with SingleTickerProviderStateMixin {
  String _title = "Refresher Demo";

  double percentage = 0.0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text(_title), actions: [
        IconButton(
          icon: Icon(Icons.navigate_next),
          onPressed: () {
            Navigator.push(context,
                MaterialPageRoute(builder: (BuildContext context) => InfiniteRefresherDemo()));
          },
        )
      ]),
      body: Refresher(
          loadingSize: 50.0,
          margin: EdgeInsets.all(8.0),
          onRefresh: () async {
            int counter = 0;
            Timer.periodic(Duration(milliseconds: 1000), (t) {
              counter++;
              if (this.mounted)
                setState(() {
                  _title = "Fetching${List.filled(counter, ".").join()}";
                  if (counter == 5) t.cancel();
                });
            });
            await Future.delayed(new Duration(milliseconds: 6000));
            if (this.mounted)
              setState(() {
                _title = "Refresher Demo";
              });
          },
          child: Column(
              children: List.generate(
            100,
            (index) => Text("Here is $index"),
          ))),
    );
  }
}

Infinite Example #

class InfiniteRefresherDemo extends StatefulWidget {
  @override
  _InfiniteRefresherDemoState createState() => _InfiniteRefresherDemoState();
}

class _InfiniteRefresherDemoState extends State<InfiniteRefresherDemo>
    with SingleTickerProviderStateMixin {
  String _title = "Infinite Refresher Demo";
  List<Widget> _children = [];
  double percentage = 0.0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text(_title),
      ),
      body: InfiniteRefresher(
        loadingSize: 50.0,
        margin: EdgeInsets.all(8.0),
        onRefresh: () async {
          int counter = 0;
          Timer.periodic(Duration(milliseconds: 1000), (t) {
            counter++;
            if (this.mounted)
              setState(() {
                _title = "Fetching${List.filled(counter, ".").join()}";
                if (counter == 5) t.cancel();
              });
          });
          await Future.delayed(new Duration(milliseconds: 1000));
          _children.clear();
          _children.addAll(List.generate(
            Random().nextInt(100),
                (index) => Text("Here is $index"),
          ));
          if (this.mounted)
            setState(() {
              _title = "Infinite Refresher Demo";
            });
        },
        widgetBuilder: (context) {
          return Column(children: _children);
        },
        fetcher: (context, cursor) async {
          await Future.delayed(Duration(milliseconds: 3000));

          _children.addAll(List.generate(
            Random().nextInt(100),
            (index) => Text("Here is $index"),
          ));

          return true;
        },
      ),
    );
  }
}

1.0.1+1 - 19 februari 2020 #

  • merge all typedefs

1.0.1 - 15 februari 2020 #

  • add refresher builder

1.0.0+2 #

  • Add LoadingAnimation.defaultLineColor and LoadingAnimation.defaultProgressColor

1.0.0+1 #

  • Fix scroll to the max
  • Fix refresher

1.0.0 #

  • Stable version
  • Add cursor and noMoreData arguments on InfiniteListView and RefresherInfinite to resume progress whenever changing tab
  • Add flag should scroll to the max whenever scrolling to bottom most

0.0.4+2 #

  • Refresher and Infinite Refresher only supports vertical axis
  • Because NotificationListener
  • Ideally there will be no vertical scrollable inside another vertical scrollable
  • that's why to prevent this issue, _handleScrollNotification only fired when it's vertical scrolling

0.0.4+1 #

  • Documentation fix

0.0.4 #

  • Fix Android AlwaysScrollPhysics clamping problem.

0.0.3+2 #

  • Disable Refresh when doing Fetch More Data and vice versa.

0.0.3+1 #

  • Add new reset function without fetch new data (because it's handled at the front).

0.0.3 #

  • Add Refresher combined with InfiniteListView (InfiniteRefresher).

0.0.2 #

  • Add margin and loading size to argument, also scrollController is injectable from the outside world.
  • Temporarily scroll functionality is disabled after it reaches for refresh height.

0.0.1+1 #

  • Minor bug fix.

0.0.1 #

  • Initial release.

example/lib/main.dart

import 'dart:async';
import 'dart:math';

import 'package:flutter/material.dart';
import 'package:refresher/refresher.dart';
import 'package:refresher_example/infinite_demo.dart';

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: RefresherDemo(),
    );
  }
}

class RefresherDemo extends StatefulWidget {
  @override
  _RefresherDemoState createState() => _RefresherDemoState();
}

class _RefresherDemoState extends State<RefresherDemo> with SingleTickerProviderStateMixin {
  String _title = "Refresher Demo";
  List<Widget> _children = [];

  double percentage = 0.0;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _children = List.generate(
      Random().nextInt(100),
          (index) => Text("Here is $index"),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text(_title), actions: [
        IconButton(
          icon: Icon(Icons.navigate_next),
          onPressed: () {
            Navigator.push(context,
                MaterialPageRoute(builder: (BuildContext context) => InfiniteRefresherDemo()));
          },
        )
      ]),
      body: Refresher(
          loadingSize: 50.0,
          margin: EdgeInsets.all(8.0),
          onRefresh: () async {
            int counter = 0;
            Timer.periodic(Duration(milliseconds: 1000), (t) {
              counter++;
              if (this.mounted)
                setState(() {
                  _title = "Fetching${List.filled(counter, ".").join()}";
                  if (counter == 5) t.cancel();
                });
            });
            await Future.delayed(new Duration(milliseconds: 6000));
            if (this.mounted)
              setState(() {
                _title = "Refresher Demo";
                _children = List.generate(
                  Random().nextInt(100),
                  (index) => Text("Here is $index"),
                );
              });
          },
          child: Column(children: _children)),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  refresher: ^1.0.1+1

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

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

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:refresher/refresher.dart] that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because of import path [package:refresher/refresher.dart] that declares support for platforms: android, ios

Package does not support Flutter platform web

Because of import path [package:refresher/refresher.dart] that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because of import path [package:refresher/refresher.dart] that declares support for platforms: android, ios

Package not compatible with SDK dart

because of import path [refresher] that is in a package requiring null.

Health suggestions

Fix lib/infinite_list_view.dart. (-0.50 points)

Analysis of lib/infinite_list_view.dart reported 1 hint:

line 1 col 8: Unused import: 'dart:async'.

Format lib/always_bouncing_physics.dart.

Run flutter format to format lib/always_bouncing_physics.dart.

Format lib/loading_animation.dart.

Run flutter format to format lib/loading_animation.dart.

Fix additional 3 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/not_bouncing_physics.dart (Run flutter format to format lib/not_bouncing_physics.dart.)
  • lib/refresh_indicator_physics.dart (Run flutter format to format lib/refresh_indicator_physics.dart.)
  • lib/typedefs.dart (Run flutter format to format lib/typedefs.dart.)

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8