isConnected method Null safety

  1. @override
Future<bool> isConnected()
override

Implementation

@override
Future<bool> isConnected() async {
  try {
    final result = await InternetAddress.lookup('google.com');
    if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
      return true;
    }
  } on SocketException catch (e) {
    log(e.message, name: 'isConnected', error: e);
  }
  return false;
}