cached_builder 1.0.1
cached_builder: ^1.0.1 copied to clipboard
A smart FutureBuilder replacement with built-in caching, retry, and stale-while-revalidate strategies. Integrated with connectivity_plus_wrapper for smart network awareness.
cached_builder π + πΆ #
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