loadany 0.1.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 85

LoadAny #

A new Flutter loads more package.

中文说明

Codemagic build status

Support #

  • CustomScrollView
  • SliverListView
  • SliverGridView
  • SliverListView substitute ListView
  • SliverGridView substitute GridView
  • Custom loading style
  • External nested RefreshIndicator
  • Feed streaming

Usage #

  • Add LoadAny
import 'package:loadany/loadany.dart';
LoadStatus status = LoadStatus.normal;

LoadAny(
  onLoadMore: getLoadMore,
  status: status,
  footerHeight: 40,
  endLoadMore: true,
  bottomTriggerDistance: 200,
  child: CustomScrollView(
    slivers: <Widget>[
      SliverGrid(...),
      SliverList(...),
    ],
  ),
)
/// Load More Get Data
Future<void> getLoadMore() async {
    setState(() {
      status = LoadStatus.loading;
    });
    Timer.periodic(Duration(milliseconds: 5000), (Timer timer) {
      timer.cancel();
      int length = list.length;
      for (var i = 1; i < 11; ++i) {
        list.add(length + i);
      }
    
      if (length > 80) {
        status = LoadStatus.completed;
      } else if (length >= 50 && length < 70) {
        status = LoadStatus.error;
      } else {
        status = LoadStatus.normal;
      }
      setState(() {});
    });
}

Getting Started #

Getting Started

Screenshot #

  • Loading
  • Error
  • Completed

Issues and feedback #

Please file issues to send feedback or report a bug. Thank you!

[0.1.2] - 2019-08-27

  • 修复示例依赖失败的问题
  • 增加自动化构建状态

[0.1.1] - 2019-08-09

  • 添加中文说明
  • 添加中文入门文档

[0.1.0] - 2019-07-25

  • CustomScrollView
  • SliverListView
  • SliverGridView
  • SliverListView substitute ListView
  • SliverGridView substitute GridView
  • Custom loading style
  • External nested RefreshIndicator
  • Feed streaming

example/README.md

LoadAny Example #

A example Flutter application of LoadAny.

中文说明

Codemagic build status

Getting Started #

import 'package:loadany/loadany.dart';
LoadStatus status = LoadStatus.normal;

LoadAny(
  onLoadMore: getLoadMore,
  status: status,
  child: CustomScrollView(
    slivers: <Widget>[
      SliverGrid(...),
      SliverList(...),
    ],
  ),
)
/// Load More Get Data
Future<void> getLoadMore() async {
    setState(() {
      status = LoadStatus.loading;
    });
    Timer.periodic(Duration(milliseconds: 5000), (Timer timer) {
      timer.cancel();
      int length = list.length;
      for (var i = 1; i < 11; ++i) {
        list.add(length + i);
      }
    
      if (length > 80) {
        status = LoadStatus.completed;
      } else if (length >= 50 && length < 70) {
        status = LoadStatus.error;
      } else {
        status = LoadStatus.normal;
      }
      setState(() {});
    });
}
LoadAny(
  onLoadMore: getLoadMore,
  status: status,
  footerHeight: 40, // Add
  child: CustomScrollView(
    slivers: <Widget>[
      SliverGrid(...),
      SliverList(...),
    ],
  ),
)

Set the feed trigger flow bottom trigger timing height #

LoadAny(
  onLoadMore: getLoadMore,
  status: status,
  endLoadMore: false, // Add
  bottomTriggerDistance: 200, // Add
  child: CustomScrollView(
    slivers: <Widget>[
      SliverGrid(...),
      SliverList(...),
    ],
  ),
)
LoadAny(
  onLoadMore: getLoadMore,
  status: status,
  loadMoreBuilder: (BuildContext context, LoadStatus status) {
    if (status == LoadStatus.loading) {
      return Container(
        height: 40,
        child: Text('Loading'),
        color: Colors.green,
        alignment: Alignment.center,
      );
    }
    return null;
  },
  child: CustomScrollView(
    slivers: <Widget>[
      SliverGrid(...),
      SliverList(...),
    ],
  ),
)

Add RefreshIndicator to refresh #

RefreshIndicator(
    onRefresh: () async {
      if(status==LoadStatus.normal) {
        await GetData();
        ...
        setState(() {});
      }
    },
    child: LoadAny(
      onLoadMore: getLoadMore,
      status: status,
      child: CustomScrollView(
        slivers: <Widget>[
          SliverAppBar(...),
          SliverGrid(...),
          SliverList(...),
        ],
      ),
    ),
)

Use this package as a library

1. Depend on it

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


dependencies:
  loadany: ^0.1.2

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:loadany/loadany.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
70
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]
85
Learn more about scoring.

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

  • Dart: 2.6.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.6

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

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