Why is Flutter WebView not loading page?

1,385

Solution 1

This code work for me. Try this out

return Scaffold(
  appBar: AppBar(
    title: Text('test'),
  ),
  body: Column(
    children: [
      RaisedButton(
        onPressed: () {},
        child: Text('Test'),
      ),
      Expanded(
        child: WebView(
          initialUrl: 'https://flutter.dev',
          javascriptMode: JavascriptMode.unrestricted,
        ),
      ),
   
    ],
  ),
);

Cheack the screenshot

Solution 2

******Give Internet Permission in Android Manifest.xml file and the permission is below

https://stackoverflow.com/questions/55603979/why-cant-a-flutter-application-connect-to-the-internet-when-installing-app-rel


<manifest xmlns:android="...">
  <uses-permission android:name="android.permission.INTERNET"/>
</manifast>
Share:
1,385
Noor
Author by

Noor

Love programming, designing system, their architectures, fond of client side web programming using javascript frameworks such as angularjs, emberjs or other like GWT

Updated on January 01, 2023

Comments

  • Noor
    Noor over 1 year

    I am making a simple screen containing a WebView encapsulated inside a Scaffold. There is a button above the WebView. The WebView is not loading the page. However, when the WebView is not encapsulated inside the Scaffold, the page loads. I need to have the Scaffold as a container to add other widgets. How to make the WebView loads its page inside the Scaffold.

    Codes containing WebView inside Scaffold. WebView does not load

    return MaterialApp(
          home: Scaffold(
              body: Column(
              mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  TextButton(
                    onPressed: () {
                     
                    },
                    child: Text('Print page'),
                  ),
                  WebView(
                    initialUrl: 'https://flutter.dev',
                  )
              ],),),
        );
    

    Codes containing only WebView. WebView does not load

       return MaterialApp(
          home: WebView(
            initialUrl: 'https://flutter.dev',
          ),
        );
    
    • Ankit Tale
      Ankit Tale over 2 years
      if you are using the Flutter community Plugin of Webview. Then you need to use WebViewScaffold. Please check this medium link medium.com/@zeyadelosherey/…
  • Saif Khan
    Saif Khan over 2 years