incrementally_loading_listview 0.2.0

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

incrementally_loading_listview #

An extension of the Flutter ListView widget for incrementally loading items upon scrolling. This could be used to load paginated data received from API requests.

NOTE: this package depends on rxdart. If you run into conflicts with different versions of rxdart, consider using dependency overrides as per this link

Getting Started #

There's a working example that can be run to see how it works.

First import the library

import 'package:incrementally_loading_listview/incrementally_loading_listview.dart';

You can then use the IncrementallyLoadingListView widget in a similar way you would with the ListView.builder constructor

return IncrementallyLoadingListView(
    hasMore: () => _hasMoreItems,
    itemCount: () => items.length,
    loadMore: () async {
    // can shorten to "loadMore: _loadMoreItems" but this syntax is used to demonstrate that
    // functions with parameters can also be invoked if needed
    await _loadMoreItems();
    },
    loadMoreOffsetFromBottom: 2,
    itemBuilder: (context, index) {
        /// your builder function for rendering the item
});

The widget allows passing in the same parameters you would to the ListView.builder constructor but itemCount is required so that when an item scrolls into view, it can see if it should attempt to load more items. Note that this is a callback that returns a boolean rather than being a boolean value. This allows the widget to not require a reference/copy of your data collection. The other parameters that can be specified are

  • hasMore: a callback that indicates if there are more items that can be loaded
  • loadMore: a callback to an asynchronous function that loads more items
  • loadMoreOffsetFromBottom: determines when the list view should attempt to load more items based on of the index of the item is scrolling into view. This is relative to the bottom of the list and has a default value of 0 so that it loads when the last item within the list view scrolls into view. As an example, setting this to 1 would attempt to load more items when the second last item within the list view scrolls into view
  • onLoadMore: a callback that is triggered when more items are being loaded. At first this will pass a boolean value of true to when items are being loaded by triggering the loadMore callback function. You could use this to update your UI to show a loading indicator
  • onLoadMoreFinished: a callback that is triggered when items have finished being loading. You can use this to hide your loading indicator

Providing onLoadMore and onLoadMoreFinished callbacks means the widget doesn't make assumptions on how you want to render a loading indicator so it will be up to your application to handle these callbacks to render the appropriate UI.

[0.2.0] 10/6/2019

  • BREAKING CHANGE Updated rxdart dependency

[0.1.0+1] 27/3/2019

  • No functional changes in this release. Changes were to fix formatting to meet Dart guidelines

[0.1.0] - 25/2/2019

  • BREAKING CHANGE Updated rxdart dependency
  • Formatted README. Thanks to PR from Mohammed Salman

[0.0.4+3] - 15/8/2018

  • Reordering changelog

[0.0.4+2] - 15/8/2018

  • BREAKING CHANGE separated onLoadMore callback. There is now an onLoadMore that doesn't pass a boolean and is triggered when more items are being loaded and onLoadMoreFinished when more items have finished being loaded.
  • Updated README to explain onLoadMore and onLoadMoreFinished

[0.0.4+1] - 15/8/2018

  • Updated README

[0.0.4] - 15/8/2018

  • BREAKING CHANGES fixed an issue that occurred where package no longer worked due to the way the list view was triggering the loading of more items. This was due to the fact that setState was being called while the build was occurred. Changed this now to use a StreamBuilder wrapped around a ListView.builder now so that upon reaching the nth item from the bottom will emit an item onto a stream that executes the function required to load more items and rebuild the ListView when the functions completes execution. As a result of these changes itemCount and hasMore are now callbacks
  • Updated sample to add navigating to an item details page for testing

[0.0.3] - 23/7/2018

  • Corrected some bad grammar in the README due to late night blogging/coding...

[0.0.2] - 21/7/2018

  • Updated license

[0.0.1] - 21/7/2018

  • Initial release

example/README.md

incrementally_loading_listview_example #

A new Flutter project.

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:
  incrementally_loading_listview: ^0.2.0

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:incrementally_loading_listview/incrementally_loading_listview.dart';
  
Version Uploaded Documentation Archive
0.2.0 Jun 10, 2019 Go to the documentation of incrementally_loading_listview 0.2.0 Download incrementally_loading_listview 0.2.0 archive
0.1.0+1 Mar 27, 2019 Go to the documentation of incrementally_loading_listview 0.1.0+1 Download incrementally_loading_listview 0.1.0+1 archive
0.1.0 Feb 25, 2019 Go to the documentation of incrementally_loading_listview 0.1.0 Download incrementally_loading_listview 0.1.0 archive
0.0.4+3 Aug 15, 2018 Go to the documentation of incrementally_loading_listview 0.0.4+3 Download incrementally_loading_listview 0.0.4+3 archive
0.0.4+2 Aug 14, 2018 Go to the documentation of incrementally_loading_listview 0.0.4+2 Download incrementally_loading_listview 0.0.4+2 archive
0.0.4+1 Aug 14, 2018 Go to the documentation of incrementally_loading_listview 0.0.4+1 Download incrementally_loading_listview 0.0.4+1 archive
0.0.4 Aug 14, 2018 Go to the documentation of incrementally_loading_listview 0.0.4 Download incrementally_loading_listview 0.0.4 archive
0.0.3 Jul 22, 2018 Go to the documentation of incrementally_loading_listview 0.0.3 Download incrementally_loading_listview 0.0.3 archive
0.0.2 Jul 21, 2018 Go to the documentation of incrementally_loading_listview 0.0.2 Download incrementally_loading_listview 0.0.2 archive
0.0.1 Jul 21, 2018 Go to the documentation of incrementally_loading_listview 0.0.1 Download incrementally_loading_listview 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
80
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
95
Overall:
Weighted score of the above. [more]
89
Learn more about scoring.

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

  • Dart: 2.3.2
  • pana: 0.12.18
  • Flutter: 1.5.4-hotfix.2

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance issues and suggestions

Support latest dependencies. (-5 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0
flutter 0.0.0
rxdart ^0.22.0 0.22.0
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test
pedantic ^1.0.0