InternetChecker class

Service that evaluates end-to-end internet reachability by probing remote targets.

Unlike interface-level detection (which only knows if the device radio is attached to Wi-Fi or mobile data), InternetChecker verifies whether packets can actually reach the public internet (detecting captive portals, dead uplinks, or router failures).

Features:

  • Fast low-overhead socket probes (port 53 DNS by default)
  • Target fallback (tries next target if previous times out or fails)
  • Result caching and concurrent request deduplication to save battery/bandwidth
  • Pluggable probe function for custom environments and deterministic unit testing

Constructors

InternetChecker({InternetCheckOptions? options, SocketProbe? probe})
Creates an InternetChecker with optional configuration options and custom probe.

Properties

hashCode → int
The hash code for this object.
no setterinherited
hasValidCache → bool
Whether a valid cached reachability result is currently available.
no setter
lastResult → bool?
The most recently evaluated reachability result, if any.
no setter
options → InternetCheckOptions
The configuration options governing targets and caching.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

checkInternetAccess({bool forceRefresh = false}) → Future<bool>
Verifies whether the public internet is reachable.
clearCache() → void
Clears any cached reachability evaluation result.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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

Static Methods

defaultSocketProbe(InternetCheckTarget target) → Future<bool>
Default socket probe implementation using dart:io Socket.connect.