CheckInternet class

A singleton class to check and monitor internet connectivity status.

The CheckInternet class periodically checks the device's internet connection by attempting to look up 'google.com'. It exposes the current connection status via the status getter and allows starting and stopping the periodic checks.

Usage:

CheckInternet.instance.init(); // Starts monitoring
var status = CheckInternet.instance.status; // Get current status
CheckInternet.instance.stop(); // Stops monitoring

The check interval can be customized using the init method's duration parameter.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
status ConnectionStatus
no setter

Methods

init({Duration duration = const Duration(seconds: 5)}) → void
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
stop() → void
Stops the periodic internet connection check by cancelling the timer.
toString() String
A string representation of this object.
inherited

Operators

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

Static Properties

instance CheckInternet
final