InternetConnectionMonitor class final
Confirms Internet status with serialized checks and periodic recovery.
Does not depend on Flutter, a network plugin, a state manager or widgets.
Feed interface events through networkChanges and call check when your
application resumes. Interface availability itself never proves Internet.
Constructors
-
InternetConnectionMonitor({InternetProbe? probe, Stream<
Object?> ? networkChanges, int failureThreshold = 2, Duration confirmationDelay = const Duration(seconds: 2), Duration retryInterval = const Duration(seconds: 10), Duration onlineInterval = const Duration(seconds: 30), Duration checkTimeout = const Duration(seconds: 10)}) - Creates an inactive monitor. Call start to enable periodic checks.
Properties
-
changes
→ Stream<
InternetStatus> -
Broadcast transitions without duplicates or replay of the current state.
no setter
- checkTimeout → Duration
-
Upper bound for the whole probe, including custom probes that never finish.
final
- confirmationDelay → Duration
-
Delay before confirming an unconfirmed failure.
final
- failureThreshold → int
-
Consecutive failed checks needed to confirm InternetStatus.offline.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isDisposed → bool
-
Whether resources were permanently released.
no setter
- onlineInterval → Duration
-
Delay between checks after an online result, even without network events.
final
- retryInterval → Duration
-
Delay between checks after an offline result.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- status → InternetStatus
-
Last confirmed state. Starts as unknown and remains readable after dispose.
no setter
Methods
-
check(
) → Future< void> - Checks now, discarding results superseded by another check request.
-
dispose(
) → Future< void> - Stops timers, cancels network events and closes the transition stream.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
start(
) → Future< void> - Starts monitoring and performs the initial check. Repeated calls are safe.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited