ConnectivityChecker class

Can be used to check whether there is internet connection to this device or not.

This simply send periodic signals to a given domain and if the requests were sent successfully this will add true to the stream. If connection was unsuccessful, this will add false to the stream.

Make sure to call close after using this instance.

Constructors

ConnectivityChecker({int refresh = 10, String domain = 'example.com'})
Can be used to check whether there is internet connection to this device or not.

Properties

domain String
Requests will be sent to this domain to check the availability of the internet. Default is example.com
final
hashCode int
The hash code for this object.
no setterinherited
refresh int
Refresh rate of the Timer in seconds. Default is 10 seconds.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
started bool
Check whether the Timer is started or not. Once the Timer is started, it cannot be stopped without calling close.
getter/setter pair
stream Stream<bool>
Get the stream associated with this instance. You can use this stream to listen to the changes in the internet connection.
no setter

Methods

checkConnectivity() Future<bool>
Instantly check whether the app has connection to the internet or not. Return true if the device is connected to the internet. Otherwise false.
close() Future<void>
Must call this method after using this instance. This method will close the Timer and release any resources that this holds.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
restart() → void
Same is start, but this will restart the Timer every time this is called.
start() → void
You have to call this method to start the Timer. You cannot use the stream without calling this function.
toString() String
A string representation of this object.
inherited

Operators

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