Flutter: Mobile webapp responsive UI render fine on mobile browser apps but not on in-app webview

788 Views Asked by At

Using webview_flutter package for showing a webview inside my application. The web page is made responsive to mobile views as well and it's loading without any issue on mobile browsers like chrome, firefox, etc. But when I'm loading the same page through my webview, it's actually not rendering as a responsive layout. It's just trying to fit whatever there on a full webpage to mobile not following any responsiveness.

    WebView(
           initialUrl: myHttpsUrl,
           javascriptMode: JavascriptMode.unrestricted,
           javascriptChannels: <JavascriptChannel>[
              _eventChannel(context),
           ].toSet(),
           gestureNavigationEnabled: false,
           onPageStarted: _pageStarted,
           onPageFinished: _pageFinished,
    ),

The same behavior observed in Android and iOS platforms.

Edit: The webpage is setting viewport meta like this:

<meta name="viewport" content="width=device-width, initial-scale=1">
1

There are 1 best solutions below

1
On

must add this meta head to html file

<head><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\" /></head>