How to show "You're offline" when web view app open without internet in Flutter Web view App?

Issue

I create a WebView app in Flutter. But when the App open without internet its showing this
enter image description here

I want to show here another image when open this app without internet.
like redirecting to a page like your not connected or something How do I do that?

Solution

You can use this Package For checking Internet connection is available or not.

bool result = await DataConnectionChecker().hasConnection;

 return Scaffold(
      body: WebView(
        if (result == true) {
        initialUrl: "https://google.com/",
        onWebViewCreated: (WebViewController webViewController){
          _controller.complete(webViewController);
        },}
        else{
          //i am not connected to any network
        }
      ) );

Answered By – Shailandra Rajput

Answer Checked By – Candace Johnson (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *