ls_refresher 0.0.3

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

features

  • Drag down refresh, pull up refresh.
  • Simply used within CustomScrollView.
  • Diy the widget displayed on over-scroll area. (use your own builder)
  • Gif image support, image changed along with drag offset.

LSTopRefresher

LSBottomRefresher

warning

LSTopRefresher is based on CupertinoRefreshControl, so it has a bug that when the items can not fill the ScrollView, it would not bounce back when refesh task completed, which exists on beta verision of flutter, but it has been fixed on its master channel

start:

import 'package:ls_refresher/ls_refresher.dart';

then:

new CustomScrollView(
            slivers: <Widget>[
//              new LSTopRefresher.image('images/test.gif', 'images/test2.gif',
//                  onRefresh: () {
//                return new Future<void>.delayed(const Duration(seconds: 2))
//                  ..then((re) {
//                    setState(() {
//                      changeRandomList();
//                    });
//                  });
//              }),
              new LSTopRefresher.simple(onRefresh: () {
                return new Future<void>.delayed(const Duration(seconds: 2))
                  ..then((re) {
                    setState(() {
                      changeRandomList();
                    });
                  });
              }),
              new SliverList(
                delegate: new SliverChildBuilderDelegate(
                  (BuildContext context, int index) {
                    return new _ListItem(
                      name: randomizedContacts[index][0] + '$index',
                      place: randomizedContacts[index][1],
                      date: randomizedContacts[index][2],
                      called: randomizedContacts[index][3] == 'true',
                    );
                  },
                  childCount: _listCount,
                ),
              ),
//              new LSBottomRefresher.simple(
//                onRefresh: () {
//                  return new Future<void>.delayed(const Duration(seconds: 2))
//                    ..then((re) {
////                      setState(() {
////                        _listCount += 1;
////                      });
//                    });
//                },
//              )
              new LSBottomRefresher.image(
                'images/test3.gif',
                'images/test4.gif',
                onRefresh: () {
                  return new Future<void>.delayed(const Duration(seconds: 2))
                    ..then((re) {
//                      setState(() {
//                        _listCount += 1;
//                      });
                    });
                },
              )
            ],
          ),

[0.0.2] - add liscense and guide infomation

       - fixed bugs

[0.0.1] - initialize.

example/lib/main.dart

// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:math' show Random;
import 'dart:ui' as ui;
import 'package:ls_refresher/ls_refresher.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/scheduler.dart';

class _DemoState extends State<Demo> {
  List<List<String>> randomizedContacts;
  List<ui.Image> rawImages = [];
  ui.Image rawImage;
  @override
  void initState() {
    super.initState();
    changeRandomList();
  }

  double outExtent = 0.0;
  int _listCount = 14;
  ScrollController _scrollController = new ScrollController();
  @override
  Widget build(BuildContext context) {
    return new DefaultTextStyle(
      style: new TextStyle(fontSize: 17.0),
      child: new Scaffold(
        appBar: new AppBar(
          title: new Text('Title'),
        ),
        body: new CustomScrollView(
          controller: _scrollController,
          physics: new AlwaysScrollableScrollPhysics(),
          slivers: <Widget>[
            new LSTopRefresher.image('images/giphy.gif', 'images/bread.gif',
                onRefresh: () {
              return new Future<void>.delayed(const Duration(seconds: 2))
                ..then((re) {
                  setState(() {
                    changeRandomList();
                  });
                });
            }),
//            new LSTopRefresher.simple(onRefresh: () {
//              return new Future<void>.delayed(const Duration(seconds: 2))
//                ..then((re) {
//                  setState(() {
//                    changeRandomList();
//                    _scrollController.animateTo(0.0,
//                        duration: new Duration(milliseconds: 100),
//                        curve: Curves.bounceOut);
//                  });
//                });
//            }),
            new SliverSafeArea(
              sliver: new SliverList(
                delegate: new SliverChildBuilderDelegate(
                  (BuildContext context, int index) {
                    return new _ListItem(
                      name: randomizedContacts[index][0] + '$index',
                      place: randomizedContacts[index][1],
                      date: randomizedContacts[index][2],
                      called: randomizedContacts[index][3] == 'true',
                    );
                  },
                  childCount: _listCount,
                ),
              ),
            ),
//              new LSBottomRefresher.simple(
//                onRefresh: () {
//                  return new Future<void>.delayed(const Duration(seconds: 2))
//                    ..then((re) {
////                      setState(() {
////                        _listCount += 1;
////                      });
//                    });
//                },
//              )
            new LSBottomRefresher.image(
              'images/ice.gif',
              'images/sea.gif',
              onRefresh: () {
                return new Future<void>.delayed(const Duration(seconds: 2))
                  ..then((re) {
                    setState(() {
                      _listCount += 1;
                    });
                  });
              },
            )
          ],
        ),
      ),
    );
  }

  void changeRandomList() {
    final Random random = new Random();
//    _listCount -= 1;
    randomizedContacts = new List<List<String>>.generate(100, (int index) {
      return contacts[random.nextInt(contacts.length)]
        // Randomly adds a telephone icon next to the contact or not.
        ..add(random.nextBool().toString());
    });
  }
}

void main() {
  //debugPaintSizeEnabled = true;
  runApp(new MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Flutter Demo',
      theme: new ThemeData().copyWith(platform: TargetPlatform.iOS),
      home: new MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

List<Widget> list = <Widget>[
  new ListTile(
    title: new Text('La Ciccia',
        style: new TextStyle(fontWeight: FontWeight.w500, fontSize: 20.0)),
    subtitle: new Text('291 30th St'),
    leading: new Icon(
      Icons.restaurant,
      color: Colors.blue[500],
    ),
  ),
];

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return new Demo();
  }
}

class Demo extends StatefulWidget {
  static const String routeName = '/cupertino/refresh';

  @override
  _DemoState createState() => new _DemoState();
}

List<List<String>> contacts = <List<String>>[
  <String>['George Washington', 'Westmoreland County', ' 4/30/1789'],
  <String>['John Adams', 'Braintree', ' 3/4/1797'],
  <String>['Thomas Jefferson', 'Shadwell', ' 3/4/1801'],
  <String>['James Madison', 'Port Conway', ' 3/4/1809'],
  <String>['James Monroe', 'Monroe Hall', ' 3/4/1817'],
  <String>['Andrew Jackson', 'Waxhaws Region South/North', ' 3/4/1829'],
  <String>['John Quincy Adams', 'Braintree', ' 3/4/1825'],
  <String>['William Henry Harrison', 'Charles City County', ' 3/4/1841'],
];

class _ListItem extends StatelessWidget {
  const _ListItem({
    this.name,
    this.place,
    this.date,
    this.called,
  });

  final String name;
  final String place;
  final String date;
  final bool called;

  @override
  Widget build(BuildContext context) {
    return new Container(
      height: 60.0,
      padding: const EdgeInsets.only(top: 9.0),
      child: new Row(
        children: <Widget>[
          new Expanded(
            child: new Container(
              decoration: const BoxDecoration(
                border: const Border(
                  bottom: const BorderSide(
                      color: const Color(0xFFBCBBC1), width: 0.0),
                ),
              ),
              padding:
                  const EdgeInsets.only(left: 1.0, bottom: 9.0, right: 10.0),
              child: new Row(
                children: <Widget>[
                  new Expanded(
                    child: new Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: <Widget>[
                        new Text(
                          name,
                          maxLines: 1,
                          overflow: TextOverflow.ellipsis,
                          style: const TextStyle(
                            fontWeight: FontWeight.w600,
                            letterSpacing: -0.41,
                          ),
                        ),
                        new Text(
                          place,
                          maxLines: 1,
                          overflow: TextOverflow.ellipsis,
                          style: const TextStyle(
                            fontSize: 15.0,
                            letterSpacing: -0.24,
                          ),
                        ),
                      ],
                    ),
                  ),
                  new Text(
                    date,
                    style: const TextStyle(
                      fontSize: 15.0,
                      letterSpacing: -0.41,
                    ),
                  ),
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  ls_refresher: ^0.0.3

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:ls_refresher/ls_refresher.dart';
  
Version Uploaded Documentation Archive
0.0.3 May 25, 2018 Go to the documentation of ls_refresher 0.0.3 Download ls_refresher 0.0.3 archive
0.0.2 May 24, 2018 Go to the documentation of ls_refresher 0.0.2 Download ls_refresher 0.0.2 archive
0.0.1 May 23, 2018 Go to the documentation of ls_refresher 0.0.1 Download ls_refresher 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
55
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]
77
Learn more about scoring.

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

  • Dart: 2.0.0
  • pana: 0.11.8
  • Flutter: 0.5.7

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Suggestions

The description is too short.

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Package is pre-v1 release.

While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction of the API.

Format lib/src/bottom_refresher.dart.

Run flutter format to format lib/src/bottom_refresher.dart.

Fix lib/src/image_stream_completer.dart.

Analysis of lib/src/image_stream_completer.dart reported 1 hint:

line 25 col 7: The value of the field '_framesEmitted' isn't used.

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.11
meta 1.1.5 1.1.6
sky_engine 0.0.99
typed_data 1.1.5 1.1.6
vector_math 2.0.6 2.0.8
Dev dependencies
flutter_test