Home > Mobile >  How to show "You're offline" when web view app open without internet on Flutter Web v
How to show "You're offline" when web view app open without internet on Flutter Web v

Time:12-06

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

I want to show here another image when open this app without internet. How do i do that?

CodePudding user response:

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
        }
      ) );

CodePudding user response:

checking the internet in flutter is only available when you are on android or ios , it's like this because when you open your web application and it comes up it means you have a connection and if it doesn't you don't have a connection so c checking internet is meaningless

  • Related