online static method

Future<bool> online()

Implementation

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