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

306

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
        }
      ) );
Share:
306
mishalhaneef
Author by

mishalhaneef

I'm Flutter Developer

Updated on January 02, 2023

Comments

  • mishalhaneef
    mishalhaneef over 1 year

    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?