flutter_network_state 1.0.0
flutter_network_state: ^1.0.0 copied to clipboard
A network-aware state management and request orchestration engine for Flutter. Provides offline/online detection, request queuing, cache strategies, automatic sync, Dio integration, and Bloc-friendly [...]
Changelog #
1.0.0 #
🎉 Initial Release #
Core
- Sealed
NetworkStatehierarchy:Idle,Loading,Offline,Syncing,Success<T>,Error - Sealed
NetworkStrategy:NetworkFirst,CacheFirst,CacheOnly,NetworkOnly - Stream-based
NetworkStatusMonitorwrappingconnectivity_plus - Pluggable
NetworkLoggerwith severity levels (debug, info, warning, error)
Request Orchestration
NetworkManager.request<T>()API with strategy-based resolution- Automatic cache fallback on network failure (NetworkFirst / CacheFirst)
- Offline request queueing with per-request retry policies
Cache
- In-memory
CacheManagerwith TTL support - Pluggable
CacheStoreinterface for custom persistence (Hive, Isar, etc.)
Queue & Sync
- FIFO
RequestQueuewith pluggableQueueStore SyncEngine— automatically drains queue on connectivity restore- Progress tracking via
Syncingstate (completedRequests / totalRequests)
Retry
RetryPolicywith configurable max retriesExponentialBackoffwith ±25% jitterLinearBackoffandConstantBackoffalternatives- Custom
shouldRetrypredicate support
Dio Integration
NetworkDioInterceptor— drop-in interceptor for anyDioinstance- Auto-retry on transient failures (timeouts, 500, 502, 503, 429)
- Automatic offline queueing and replay
- Configurable request/response/error logging
State Management
NetworkNotifier—ChangeNotifierwrapper for ProviderNetworkCubit— standalone Cubit base class (noflutter_blocdependency)executeAndEmit()/bindToEmit()— extensions forflutter_blocCubit/BlocNetworkStateNotifier— Riverpod-compatible notifier withexecute()helpercreateNotifier()— extension onNetworkManagerfor Riverpod providersasNetworkStates()— transform anyStream<T>intoStream<NetworkState>- Zero external state management dependencies — all built on Flutter SDK primitives