start method

Future<void> start()

Implementation

Future<void> start() async {
  // Emit cached state immediately for instant UI on launch.
  final cached = await _cache.read();
  if (cached != null) {
    _subject.add(ConnectivityLoaded(cached));
  }

  // Wire monitor → state.
  _monitorSub = _monitorService.stream.listen(
    _onResult,
    onError: (Object e) {
      _subject.add(ConnectivityError(e.toString()));
    },
  );

  // Start the monitor engine.
  await _monitorService.start();
}