start method
dynamic
start()
Implementation
start(){
stop();
Future.delayed(const Duration(seconds: 1), (){
_connectivitySubscription =
_connectivityManager.onConnectivityChanged.listen((ConnectivityResult conn) {
if(_isFirstTime){
_isFirstTime = false;
return;
}
_connectivity = conn;
if (conn == ConnectivityResult.none) {
getIt.get<ConnectionService>().notifyConnectionChanged(ConnectionStatus.disconnected);
logger('Lost internet connection',);
} else {
logger('Got internet connection, reconnecting...', level: Level.debug);
try {
getIt.get<ConnectionService>().reconnect();
} catch(e) {
logger('ReconnectWhenOffline', level: Level.error, additionalData: e);
}
}
});
});
}