onConnectivityChanged property

  1. @override
Stream<ConnectivityResult> get onConnectivityChanged
override

Implementation

@override
// Getter for onConnectivityChanged that listens to the platform's eventChannel and maps the result to ConnectivityResult events.
Stream<ConnectivityResult> get onConnectivityChanged {
  _onConnectivityChanged ??= eventChannel
      .receiveBroadcastStream()
      .map((dynamic result) => result.toString()) // Convert the event result to a String.
      .map(parseConnectivityResult); // Convert the String to a ConnectivityResult enum using the parseConnectivityResult function.
  return _onConnectivityChanged!;
}