import 'dart:async'; import 'dart:io'; import 'package:connectivity_plus/connectivity_plus.dart'; class NetworkConnectivity { // Future isInternetAvailable() async { // var connectivityResult = await (Connectivity().checkConnectivity()); // return connectivityResult != ConnectivityResult.none; // } Future isInternetAvailable() async { var connectivityResult = await Connectivity().checkConnectivity(); if (connectivityResult == ConnectivityResult.none) { return false; } else { try { final result = await InternetAddress.lookup('google.com'); if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) { return true; } return false; } on SocketException catch (_) { return false; } } } }