ConnectionChecker class

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

Constructors

ConnectionChecker({Duration? timeout, Duration? timeInterval, List<AddressOption>? addresses, bool useDefaultOptions = true, bool useConnectivityPlus = false})
This is a singleton that can be accessed like a regular constructor i.e. ConnectionChecker() always returns the same instance.
factory

Properties

addresses List<AddressOption>
Set a list of CheckOptions to the address Once set other previous options will be removed and only the new options will be used If the list is empty, the default options will be used
no getter
connectionStatus Future<ConnectionStatus>
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 ConnectionStatus.connected. ConnectionStatus.disconnected otherwise.
no setter
failedRequests List<AddressConnectionResult>?
A list of AddressConnectionResult with the Exception occured.
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 onConnectivityChanged
no setter
lastStatus ConnectionStatus?
no setter
onConnectivityChanged Stream<ConnectionStatus>
Subscribe to this stream to receive events whenever the ConnectionStatus changes. When a listener is attached a check is performed immediately and the status (ConnectionStatus) 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
timeInterval Duration
Interval is the time between automatic checks Periodic checks are only made if there's an attached listener to onConnectivityChanged. If that's the case onConnectivityChanged emits an update only if there's change from the previous status.
getter/setter pair
timeout Duration
Defaults to (10 seconds). If set then timeout will be used for all default address checks. Can provide different for each address individually.
getter/setter pair
useConnectivityPlus bool
getter/setter pair

Methods

checkConnectivity(AddressOption options) Future<AddressConnectionResult>
Ping a single address. See AddressOption for info on the accepted argument.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setDefaultOptionsTrue() → void
Adds the Default CheckOptions to the addresses
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

newInstance({Duration? timeout, Duration? timeInterval, List<AddressOption>? addresses, bool useDefaultOptions = true, bool useConnectivityPlus = false}) ConnectionChecker