NetworkWatcher class

Main class for monitoring network connectivity and managing offline requests

Constructors

NetworkWatcher.new({NetworkWatcherConfig config = NetworkWatcherConfig.defaultConfig})
Creates a new NetworkWatcher instance

Properties

config NetworkWatcherConfig
Configuration for the network watcher
final
connectivityStream Stream<ConnectivityState>
Stream of connectivity state changes
no setter
currentConnectivityState ConnectivityState
Current connectivity state
no setter
deadLetterQueue DeadLetterQueue?
Gets access to the dead letter queue if enabled
no setter
deadLetterQueueSize int
Number of requests in the dead letter queue
no setter
hashCode int
The hash code for this object.
no setterinherited
isActive bool
For testing: expose active state
no setter
isOffline bool
Whether the device is currently offline
no setter
isOnline bool
Whether the device is currently online
no setter
onlineStream Stream<bool>
Stream of online/offline status changes
no setter
queuedRequests List<NetworkRequest>
List of all requests in the offline queue
no setter
queueSize int
Number of requests currently in the offline queue
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

checkConnectivity() Future<void>
Forces a connectivity check
clearQueue() Future<void>
Clears all requests from the queue
dispose() Future<void>
Disposes of all resources
getQueueStatistics() Map<String, dynamic>
Gets comprehensive queue statistics including retry and dead letter queue info
getRequestsReadyForRetry() List<NetworkRequest>
Gets all requests that are ready for retry
getRetryStats(String requestId) Map<String, dynamic>
Gets retry statistics for a specific request
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
processQueue() Future<void>
Manually processes the offline queue
queueRequest(NetworkRequest request) Future<void>
Queues a network request for execution when online
removeRequest(String requestId) Future<bool>
Removes a specific request from the queue
start() Future<void>
Starts monitoring network connectivity
stop() Future<void>
Stops monitoring network connectivity
toString() String
A string representation of this object.
inherited
updateConnectivityState(ConnectivityState state) → void
For testing: expose connectivity state update

Operators

operator ==(Object other) bool
The equality operator.
inherited