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 material.io 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:

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

CachedRawBuilder

CachedRawCustomScrollView

CachedCustomScrollView

CachedListView

Libraries

cached_listview

Dart

VM

dart:ffi
Foreign Function Interface for interoperability with the C programming language. [...]

Web

dart:html
HTML elements and other resources for web-based applications that need to interact with the browser and the DOM (Document Object Model). [...]
dart:js
Low-level support for interoperating with JavaScript. [...]
dart:js_util
Utility methods to efficiently manipulate typed JSInterop objects in cases where the name to call is not known at runtime. You should only use these methods when the same effect cannot be achieved with @JS annotations. These methods would be extension methods on JSObject if Dart supported extension methods.