'how to make flutter app check for data access, not just wifi or mobile connection, i have tried everything

im developing a flutter app that i want to make it connect to the internet, i have tried the flutter Connectivity, connectivity_plus, but these packages don't detect data access, the only detect mobile or WiFi connection and acts as if it is online though there is no data access, i have also tried data_connection_checker and internet_connection _checker, but i think i was not able to implement them well, i want the body of my statefull widget to be determined based on the the internet access, when online body: Body() appear, when offline: NoConnectionPage() should appear, and also to continue check for internet access through the app.



Solution 1:[1]

I use this:

  Future<bool> checkIfInternetIsAvailable () async {
    final result = await InternetAddress.lookup('example.com');
    if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
      return true;
    } else{
      return false;
    }
  }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Aplamis