DataConnectionChecker class

This is a singleton that can be accessed like a regular constructor i.e. DataConnectionChecker() always returns the same instance.

Constructors

DataConnectionChecker()
This is a singleton that can be accessed like a regular constructor i.e. DataConnectionChecker() always returns the same instance.
factory

Properties

addresses List<AddressCheckOptions>
A list of internet addresses (with port and timeout) to ping.
getter/setter pair
checkInterval Duration
The interval between periodic checks. Periodic checks are only made if there's an attached listener to onStatusChange. If that's the case onStatusChange emits an update only if there's change from the previous status.
getter/setter pair
connectionStatus Future<DataConnectionStatus>
Initiates a request to each address in addresses. If at least one of the addresses is reachable we assume an internet connection is available and return true DataConnectionStatus.connected. DataConnectionStatus.disconnected otherwise.
no setter
hasConnection Future<bool>
Initiates a request to each address in addresses. If at least one of the addresses is reachable we assume an internet connection is available and return true. false otherwise.
no setter
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Returns true if there are any listeners attached to onStatusChange
no setter
isActivelyChecking bool
Alias for hasListeners
no setter
lastTryResults List<AddressCheckResult>
Returns the results from the last check.
no setter
onStatusChange Stream<DataConnectionStatus>
Subscribe to this stream to receive events whenever the DataConnectionStatus changes. When a listener is attached a check is performed immediately and the status (DataConnectionStatus) is emitted. After that a timer starts which performs checks with the specified interval - checkInterval. Default is DEFAULT_INTERVAL.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

isHostReachable(AddressCheckOptions options) Future<AddressCheckResult>
Ping a single address. See AddressCheckOptions for info on the accepted argument.
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 Properties

DEFAULT_ADDRESSES List<AddressCheckOptions>
Predefined reliable addresses. This is opinionated but should be enough. See https://www.dnsperf.com/#!dns-resolvers
final

Constants

DEFAULT_INTERVAL → const Duration
Default interval is 10 seconds
DEFAULT_PORT → const int
More info on why default port is 53 here:
DEFAULT_TIMEOUT → const Duration
Default timeout is 10 seconds.