flutter_pagewise 1.0.0

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

A library for widgets that load their content one page (or batch) at a time (also known as lazy-loading).

Features

  • Load data one page at a time
  • Retry failed pages
  • Override the default loading, retry, and error widgets if desired
  • ListView and GridView implementations
  • Extendability using inheritance

Breaking Change Starting V1.0.0:

The library has been rewritten in version 1.0.0 to provide a more efficient implementation that does not require a totalCount parameter and shows only one loading sign when users scroll down. In addition, a new parameter has been added to itemBuilder callback to provide the index if needed by the user.

Installing the library:

Like any other package, add the library to your pubspec.yaml dependencies:

dependencies:
    flutter_pagewise:

Then import it wherever you want to use it:

import 'package:flutter_pagewise/flutter_pagewise.dart';

Using the library

The library provides two main widgets:

  • PagewiseGridView: A pagewise implementation of GridView. It could be used as follows:
 PagewiseGridView.count(
   pageSize: 10,
   crossAxisCount: 2,
   mainAxisSpacing: 8.0,
   crossAxisSpacing: 8.0,
   childAspectRatio: 0.555,
   padding: EdgeInsets.all(15.0),
   itemBuilder: (context, entry, index) {
     // return a widget that displays the entry's data
   },
   pageFuture: (pageIndex) {
     // return a Future that resolves to a list containing the page's data
   },
 );
  • PagewiseListView: A pagewise implementation of ListView. It could be used as follows:
 PagewiseListView(
   pageSize: 10,
   padding: EdgeInsets.all(15.0),
   itemBuilder: (context, entry, index) {
     // return a widget that displays the entry's data
   },
   pageFuture: (pageIndex) {
     // return a Future that resolves to a list containing the page's data
   }
 );

The classes provide all the properties of ListViews and GridViews. In addition, you must provide the itemBuilder, which tells Pagewise how you want to render each element, and pageFuture, which Pagewise calls to fetch new pages. Please note that pageFuture must not return more values than mentioned in the pageSize parameter.

Customizing the widget:

In addition to the required parameters, Pagewise provides you with optional parameters to customize the widget. You have loadingBuilder, errorBuilder, and retryBuilder to customize the widgets that show on loading, error, and retry respectively.

The loadingBuilder can be used as follows:

loadingBuilder: (context) {
  return Text('Loading...');
}

The retryBuilder can be used as follows:

retryBuilder: (context, callback) {
  return RaisedButton(
    child: Text('Retry'),
    onPressed: () => callback()
  );
}

Thus, the retryBuilder provides you with a callback that you can call when you want to retry.

The errorBuilder is only relevant when showRetry is set to false, because, otherwise, the retryBuilder is shown instead. The errorBuilder can be used as follows:

errorBuilder: (context, error) {
  return Text('Error: $error');
}

Check the classes' documentation for more details.

Creating your own Pagewise Widgets:

You need to inherit from the Pagewise class. Check the code of PagewiseListView and PagewiseGridView for examples

0.1.0 - 29/07/2018.

  • Provided basic functionality for Pagewise class, PagewiseGridView class and PagewiseListView class.

0.1.1 - 29/07/2018.

  • Small fix to README.

0.1.2 - 29/07/2018.

  • Add gif to README.

0.2.0 - 31/07/2018.

  • Replace loadingWidget with a loadingBuilder that accepts a BuildContext and returns a widget.
  • Fix environment constraints in pubspec.yaml
  • Make the example better looking, and the demo as well
  • Mention lazy-loading in the README.
  • Reformat the code using flutter format

0.3.0 - 04/08/2018.

0.4.0 - 11/08/2018

  • Make future final in _FutureBuilderWrapper
  • Remove unneeded _pages data structure and operations
  • Provide ItemListBuilder for cases where we want to build a list of widgets for each data entry
  • Provide controller property to allow custom ScrollController

0.4.1 - 17/08/2018

  • Decrease size of GIF in README to make it load faster

0.5.0 - 22/08/2018

  • Provide ability to retry
  • Fix case of page futures refiring when rebuilt

1.0.0 - 16/12/2018

  • Re-architect the library for more efficiency and ease of use.

example/README.md

example

Example of using the pagewise package

Getting Started

For help getting started with Flutter, view our online documentation.

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_pagewise: ^1.0.0

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:flutter_pagewise/flutter_pagewise.dart';
  
Version Uploaded Documentation Archive
1.0.0 Dec 16, 2018 Go to the documentation of flutter_pagewise 1.0.0 Download flutter_pagewise 1.0.0 archive
0.5.0 Aug 22, 2018 Go to the documentation of flutter_pagewise 0.5.0 Download flutter_pagewise 0.5.0 archive
0.4.1 Aug 17, 2018 Go to the documentation of flutter_pagewise 0.4.1 Download flutter_pagewise 0.4.1 archive
0.4.0 Aug 11, 2018 Go to the documentation of flutter_pagewise 0.4.0 Download flutter_pagewise 0.4.0 archive
0.3.0 Aug 3, 2018 Go to the documentation of flutter_pagewise 0.3.0 Download flutter_pagewise 0.3.0 archive
0.2.0 Jul 30, 2018 Go to the documentation of flutter_pagewise 0.2.0 Download flutter_pagewise 0.2.0 archive
0.1.2 Jul 29, 2018 Go to the documentation of flutter_pagewise 0.1.2 Download flutter_pagewise 0.1.2 archive
0.1.1 Jul 29, 2018 Go to the documentation of flutter_pagewise 0.1.1 Download flutter_pagewise 0.1.1 archive
0.1.0 Jul 29, 2018 Go to the documentation of flutter_pagewise 0.1.0 Download flutter_pagewise 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
82
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]
91
Learn more about scoring.

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

  • Dart: 2.1.0
  • pana: 0.12.7
  • Flutter: 1.0.0

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <3.0.0
async ^2.0.7 2.0.8
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