isConectInternet static method
Since connectivity_plus 6 checkConnectivity() returns a
List<ConnectivityResult>, so comparing it to ConnectivityResult.none
was always true and this check never detected an offline device.
Note this only reports the interface the OS has attached; a device can
report mobile while the data path is not usable yet. [none] on the
other hand does mean the device is definitely offline.
Implementation
static Future<bool> isConectInternet() async {
try {
var connectResult = await Connectivity().checkConnectivity();
return !connectResult.contains(ConnectivityResult.none);
} on Exception catch (e, stackTrace) {
ErrorReporter.log(e, stackTrace);
// Do not block the caller when the plugin itself fails - let the actual
// request decide whether the network is usable.
return true;
}
}