isOnline static method

Future<bool> isOnline()

Checks if the device is connected to the internet.

Returns a Future

Example:

bool isOnline = await EaseDevice.isOnline();

Implementation

static Future<bool> isOnline() async {
  try {
    final result = await InternetAddress.lookup('google.com');
    return result.isNotEmpty && result[0].rawAddress.isNotEmpty;
  } on SocketException catch (_) {
    return false;
  }
}