loadmore 1.0.1

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

loadmore

pub package Hex.pm

A loadMore library

only support listview

中文构思思路和使用说明可以看简书

screenshot

img

whole example

show https://github.com/CaiJingLong/flutter_listview_loadmore

install

in pubspec.yaml

dependencies:
  loadmore: ^1.0.1

import in dartfile:

import 'package:loadmore/loadmore.dart';

use in build:

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text(widget.title),
      ),
      body: Container(
        child: LoadMore(
          isFinish: count >= 60,
          onLoadMore: _loadMore,
          child: ListView.builder(
            itemBuilder: (BuildContext context, int index) {
              return Container(
                child: Text(list[index].toString()),
                height: 40.0,
                alignment: Alignment.center,
              );
            },
            itemCount: count,
          ),
        ),
      ),
    );
  }

  Future<bool> _loadMore() async {
    print("onLoadMore");
    await Future.delayed(Duration(seconds: 0, milliseconds: 100));
    load();
    return true;
  }

properties use:

child: Widget ,required , support ListView ListView.builder ListView.separated, other is not support.
onLoadMore:required A Function , `typedef Future<bool> FutureCallBack();` , reture true is success and status delay,return false or null ,then the status will change to fail.
isFinish: bool, optional, if true, then the status will change to finish ,default is false
delegate: LoadMoreDelegate,optional, see the LoadMoreDelegate class,default is DefaultLoadMoreDelegate
textBuilder: optional, the result will show in loading view ,if you use default delegate. default is DefaultLoadMoreText.chinese,
whenEmptyLoad: bool ,optional, default is true, when [whenEmptyLoad] is true, and when listView children length is 0,or the itemCount is 0,not build loadMoreWidget.
abstract class LoadMoreDelegate {
  const LoadMoreDelegate();

  double widgetHeight(LoadMoreStatus status) => _defaultLoadMoreHeight; // the loadMore height. default is 80.0

  Duration loadMoreDelay() => Duration(milliseconds: _loadMoreDelay);// When widget is created, the refresh delay time is triggered.

  Widget buildChild(LoadMoreStatus status); // build your widget in the loadmore widget.
}

other

homePage: https://github.com/CaiJingLong/flutter_listview_loadmore emailto me : cjl_spy@163.com

LICENSE

APACHE 2.0

[1.0.1]

update readme

[1.0.0]

update readme first realease version

[0.1.2]

add a property whenEmptyLoad

[0.1.1]

update readme

[0.1.0+1] update example

[0.1.0] update readme

[0.0.2] update text

the text can set use default style

[0.0.1] first version

example/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:loadmore/loadmore.dart';

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Flutter Demo',
      theme: new ThemeData(
        primarySwatch: Colors.red,
      ),
      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();
}

class _MyHomePageState extends State<MyHomePage> {
  int get count => list.length;

  List<int> list = [];

  void initState() {
    super.initState();
    // list.addAll(List.generate(30, (v) => v));
  }

  void load() {
    setState(() {
      list.addAll(List.generate(15, (v) => v));
    });
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text(widget.title),
      ),
      body: Container(
        child: RefreshIndicator(
          child: LoadMore(
            isFinish: count >= 60,
            onLoadMore: _loadMore,
            child: ListView.builder(
              itemBuilder: (BuildContext context, int index) {
                return Container(
                  child: Text(list[index].toString()),
                  height: 40.0,
                  alignment: Alignment.center,
                );
              },
              itemCount: count,
            ),
            delegate: DefaultLoadMoreDelegate(),
            textBuilder: DefaultLoadMoreTextBuilder.chinese,
          ),
          onRefresh: _refresh,
        ),
      ),
    );
  }

  Future<bool> _loadMore() async {
    print("onLoadMore");
    await Future.delayed(Duration(seconds: 0, milliseconds: 2000));
    load();
    return true;
  }

  Future<void> _refresh() async {
    await Future.delayed(Duration(seconds: 0, milliseconds: 2000));
    list.clear();
    load();
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  loadmore: ^1.0.1

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:loadmore/loadmore.dart';
  
Version Uploaded Documentation Archive
1.0.1 Sep 14, 2018 Go to the documentation of loadmore 1.0.1 Download loadmore 1.0.1 archive
1.0.0 Sep 14, 2018 Go to the documentation of loadmore 1.0.0 Download loadmore 1.0.0 archive
0.1.2 Sep 7, 2018 Go to the documentation of loadmore 0.1.2 Download loadmore 0.1.2 archive
0.1.1 Sep 3, 2018 Go to the documentation of loadmore 0.1.1 Download loadmore 0.1.1 archive
0.1.0 Sep 2, 2018 Go to the documentation of loadmore 0.1.0 Download loadmore 0.1.0 archive
0.0.2 Sep 1, 2018 Go to the documentation of loadmore 0.0.2 Download loadmore 0.0.2 archive
0.0.1 Sep 1, 2018 Go to the documentation of loadmore 0.0.1 Download loadmore 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
64
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]
82
Learn more about scoring.

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

  • Dart: 2.0.0
  • pana: 0.12.6
  • Flutter: 0.11.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.28.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test