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
.
- 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
- 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
A Flutter package that combines network connectivity awareness with intelligent caching, ensuring seamless offline-first experiences and optimized data usage.
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,
),
)
- 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
- 📱 E-commerce apps with product catalogs
- 📰 News and content apps
- 💬 Chat and messaging applications
- 🗺️ Map and location-based services
- 📊 Dashboard and analytics apps
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.
dependencies:
cached_builder: ^1.0.0
connectivity_plus_wrapper: ^1.0.1