cached_listview 2.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 79

This package is no longer maintained, because it has been moved to a new location: flutter_cached

Original documentation:

When building a screen that displays a cached list of items, there are many special cases to think about.

For example, on there are guidelines on how to handle displaying offline data, how pull-to-refresh should be implemented and when to use error banners or empty states.

This package tries to make implementing cached ListViews as easy as possible.

loading with no data in cacheloading with data in cacheloading successful
error with no data in cacheerror with data in cacheno data available

Usage #

First, create a CacheController. This will be the class that orchestrates the fetching of data.

var cacheController = CacheController<Item>(
  // Does the actual work and returns a Future<List<Item>>.
  fetcher: _downloadData,
  // Asynchronously saves a List<Item> to the cache.
  saveToCache: _saveToCache,
  // Asynchronously loads a List<Item> from the cache.
  loadFromCache: _loadFromCache,

Then you can create a CachedListView in your widget tree:

  controller: cacheController,
  itemBuilder: (context, item) => ...,
  errorBannerBuilder: (context, error) => ...,
  errorScreenBuilder: (context, error) => ...,
  emptyStateBuilder: (context) => ...,





[2.0.0] - 2019-10-12

  • Complete overhaul of the API.
  • Package moved to flutter_cached.

[1.1.5] - 2019-10-11

  • Add more examples to the demo. Now all abstraction levels are covered.
  • Fix unbound vertical height issue caused by AnimatedCrossFade.

[1.1.4] - 2019-10-11

  • Fix type propagation on CacheController's updates.

[1.1.3] - 2019-10-06

  • We now depend on the pull_to_refresh package so that we can start the refresh indicator programatically.
  • Fix missing meta dependency.

[1.1.2] - 2019-10-05

  • CachedListView now takes either an itemBuilder for building the items directly one after another in an index-agnostic deterministic way or it takes an itemSliverBuilder for transforming all the items into slivers simultaneously, allowing for changing the order, grouping etc of items.

[1.1.1] - 2019-10-04

  • Fix type propagation for CachedCustomScrollView.

[1.1.0] - 2019-10-04

  • Add abstraction level below CachedListView: CachedCustomScrollView.
  • Rename CacheManager to CacheController.
  • Update readme to reflect changes and display screenshots in table.

[1.0.0] - 2019-10-04

  • Add CacheManager and CachedListView.


example #

A new Flutter project.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

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

  cached_listview: ^2.0.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:cached_listview/cached_listview.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

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

  • Dart: 2.6.1
  • pana: 0.13.1+4
  • Flutter: 1.12.13+hotfix.2


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.2 <3.0.0
flutter 0.0.0
list_diff ^1.1.1 1.1.3
meta ^1.1.7 1.1.8
pull_to_refresh ^1.5.6 1.5.7
Transitive dependencies
async 2.4.0
collection 1.14.11 1.14.12
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies