flutter_pagewisepackage

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

Manage loading of data more closely using a PagewiseLoadController

ListView and GridView implementations

SliverList and SliverGrid 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 the following widgets:

PagewiseGridView: A pagewise implementation of GridView. It could be
used as follows:

PagewiseSliverGrid: A pagewise implementation of SliverGrid. It could be used similar to PagewiseGridView for cases where a sliver is needed.

PagewiseSliverList: A pagewise implementation of SliverList. It could be used similar to PagewiseListView for cases where a sliver is needed.

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, noItemsFoundBuilder, and retryBuilder to customize the widgets that show
on loading, error, no found items and retry respectively.

Another use case for creating the controller yourself is if you want to
listen to the state of Pagewise and act accordingly.
For example, you might want to show a snackbar when we reach the end of the list
In that case, you could do: