This package is no longer maintained, because it has been moved to a new location: flutter_cached
When building a screen that displays a cached list of items, there are many special cases to think about.
This package tries to make implementing cached ListViews as easy as possible.
|loading with no data in cache||loading with data in cache||loading successful|
|error with no data in cache||error with data in cache||no data available|
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) => ..., ),
[2.0.0] - 2019-10-12
- Complete overhaul of the API.
- Package moved to
[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
[1.1.4] - 2019-10-11
- Fix type propagation on
[1.1.3] - 2019-10-06
- We now depend on the
pull_to_refreshpackage so that we can start the refresh indicator programatically.
- Fix missing meta dependency.
[1.1.2] - 2019-10-05
CachedListViewnow takes either an
itemBuilderfor building the items directly one after another in an index-agnostic deterministic way or it takes an
itemSliverBuilderfor 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
[1.1.0] - 2019-10-04
- Add abstraction level below
- Update readme to reflect changes and display screenshots in table.
[1.0.0] - 2019-10-04
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:
dependencies: cached_listview: ^2.0.0
2. Install it
You can install packages from the command line:
$ 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:
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]
We analyzed this package on Oct 16, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
- Dart: 2.5.1
- pana: 0.12.21
- Flutter: 1.9.1+hotfix.4
Detected platforms: Flutter
References Flutter, and has no conflicting libraries.
|Dart SDK||>=2.2.2 <3.0.0|