Skip to content

A smart FutureBuilder replacement with built-in caching, retry, and stale-while-revalidate strategies. Integrated with connectivity_plus_wrapper for smart network awareness.

License

Notifications You must be signed in to change notification settings

ahmedtalal/cached_builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cached_builder 🚀 + 📶

pub package

The ultimate caching solution for Flutter, now with smart connectivity awareness!

A seamless integration of powerful caching strategies with intelligent network status detection from connectivity_plus_wrapper.

🌟 Supercharged Features

Smart Network Integration

  • Auto-retry on reconnection: Failed requests automatically retry when network is restored
  • Offline-first caching: Aggressive caching when offline, smart revalidation when online
  • Connection-aware UI: Show different UI based on network status and data source

Advanced Caching Strategies

  • Stale-while-revalidate: Show cached data immediately, fetch fresh in background
  • Connection-based expiry: Different cache durations for online vs offline
  • Prefetching: Automatically refresh data when connection quality improves

Connectivity Wrapper with Smart Caching

A Flutter package that combines network connectivity awareness with intelligent caching, ensuring seamless offline-first experiences and optimized data usage.


🚀 Smart Usage Example

CachedBuilder(
  future: () => api.getUserData(),
  connectivityWrapper: connectivityWrapper,
  cachePolicy: ConnectivityAwareCachePolicy(
    expiry: Duration(minutes: 10),
    offlineExpiry: Duration(hours: 24),
    aggressiveCachingWhenOffline: true,
  ),
  builder: (data, isFromCache) => Column(
    children: [
      if (isFromCache) OfflineIndicator(),
      UserProfile(data: data),
    ],
  ),
  error: (error, retry, status) => ConnectionAwareError(
    error: error,
    onRetry: retry,
    connectionStatus: status,
  ),
)

🌐 Connection-Aware Benefits

  • Better Offline Experience: Data remains available for longer when offline
  • Automatic Recovery: Failed requests retry automatically when connection improves
  • Smart UI: Different indicators for cached data, offline mode, and connection issues
  • Bandwidth Optimization: Avoid unnecessary requests on unstable connections

🎯 Perfect For

  • 📱 E-commerce apps with product catalogs
  • 📰 News and content apps
  • 💬 Chat and messaging applications
  • 🗺️ Map and location-based services
  • 📊 Dashboard and analytics apps

✨ Why This Package?

This integration creates a powerful synergy between caching and network awareness, providing developers with a complete solution for building robust, offline-capable applications with excellent user experiences.

Installation

dependencies:
  cached_builder: ^1.0.0
  connectivity_plus_wrapper: ^1.0.1

About

A smart FutureBuilder replacement with built-in caching, retry, and stale-while-revalidate strategies. Integrated with connectivity_plus_wrapper for smart network awareness.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published