start method
启动监听;可重复调用(幂等)
Implementation
Future<void> start() async {
if (_started) {
await refresh();
return;
}
_started = true;
try {
final results = await _connectivity.checkConnectivity();
_apply(results, notifyCallbacks: false);
} catch (e) {
GoChatLogger.e('ConnectivityMonitor initial check failed', e);
_type = NetworkType.unknown;
}
_sub = _connectivity.onConnectivityChanged.listen(
(results) => _apply(results, notifyCallbacks: true),
onError: (Object e) => GoChatLogger.e('connectivity stream error', e),
);
GoChatLogger.d('ConnectivityMonitor started: ${_type.label}');
}