cached_future_builder_plus 0.0.2 copy "cached_future_builder_plus: ^0.0.2" to clipboard
cached_future_builder_plus: ^0.0.2 copied to clipboard

A Flutter widget that extends FutureBuilder with intelligent caching capabilities.

cached_future_builder_plus #

A Flutter widget that extends FutureBuilder with intelligent caching capabilities.

Demo GIF

Installation #

Add this package to your pubspec.yaml:

flutter pub add cached_future_builder_plus

Usage #

Replace your existing FutureBuilder with CachedFutureBuilderPlus:

import 'package:cached_future_builder_plus/cached_future_builder_plus.dart';

CachedFutureBuilderPlus<Map<String, dynamic>?>(
  cacheKey: 'todo:1', // Unique key for caching
  cachePolicy: CachePolicy.cacheThenNetwork, // Choose your cache strategy
  future: _fetchTodo(), // Your existing future
  builder: (context, snapshot) {
    if (snapshot.connectionState == ConnectionState.waiting) {
      return const CircularProgressIndicator();
    }
    
    final data = snapshot.data;
    if (data == null) {
      return const Text('No data available');
    }
    
    return Text('Title: ${data['title']}');
  },
)

Cache Policies #

  • CachePolicy.cacheOnly: Only use cached data
  • CachePolicy.networkOnly: Only fetch from network
  • CachePolicy.cacheFirst: Use cache if available, otherwise network
  • CachePolicy.networkFirst: Try network first, fallback to cache
  • CachePolicy.cacheThenNetwork: Show cache immediately, then update with network data

Additional information #

This package is built on top of the api_repo package for caching functionality. The cache key should be unique for each data source (recommended: use the API URL including query parameters).

For more information, issues, or contributions, please visit the package repository.

2
likes
160
points
33
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A Flutter widget that extends FutureBuilder with intelligent caching capabilities.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

api_repo, flutter

More

Packages that depend on cached_future_builder_plus