ConnectivityListener class

Listen network status and broadcast ConnectivityEvent event via eventBus.

// Listen ConnectivityState
var connectivityEventStream = eventBus.on<ConnectivityEvent>().listen((event) {
  if (event.state == ConnectivityState.WIFI_AVAILABLE) {
    ...
  }
});

// Start listener
ConnectivityListener.startup(['google.com', 'youtube.com']);

//
connectivityEventStream.cancel();

Constructors

ConnectivityListener()

Properties

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

Methods

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

checkState({List<String>? availabilityHosts}) Future<ConnectivityState>
Sample usage to check current state.
startup({List<String>? availabilityHosts}) → void
Start network status listen (single)
stop() → void
Stop listener