checkConnectivity static method
Future<ConnectivityResult>
checkConnectivity({
- VoidCallback? onConnected,
- VoidCallback? onDisconnected,
Check the connection status.
You can specify the callback when connected with onConnected
and
when disconnected with onDisconnected
.
Implementation
static Future<ConnectivityResult> checkConnectivity({
VoidCallback? onConnected,
VoidCallback? onDisconnected,
}) async {
final result = await Connectivity().checkConnectivity();
if (result == ConnectivityResult.none) {
onDisconnected?.call();
} else {
onConnected?.call();
}
return result;
}