platformStatusStream property
Exposes the native connectivity events as a Dart stream.
This implementation:
- Uses a Singleton-like pattern for the stream to ensure efficiency.
- Handles generic PlatformExceptions gracefully.
Implementation
@override
Stream<String> get platformStatusStream {
_onConnectivityChanged ??= eventChannel
.receiveBroadcastStream()
.map((dynamic event) => event.toString())
.handleError((error) {
debugPrint(
'RxConnectivityChecker: Platform stream error, cache cleared for reconnect: $error',
);
_onConnectivityChanged = null;
});
return _onConnectivityChanged!;
}