2

I would like to get web pages to display responsively in my Flutter apps, and am unable to do so. They display as if the screen/viewport was much wider. For example, a page that looks like this in Android Chrome:

enter image description here

ends up looking like this in my app (regardless of the package I use):

enter image description here

I have experimented with both the webview_flutter and flutter_webview_plugin packages, including experimenting with several flutter_webview_plugin functions, turning them on and off:

Future<Null> launch(String url, {
   bool withJavascript: true,
   bool enableAppScheme: true,
   bool withZoom: false,
   bool scrollBar: true,
   bool displayZoomControls: false,
   bool useWideViewPort: false,
});

I'm starting to think the solution isn't in Flutter or its packages, but maybe something like manipulating the Android manifest file (hence the android and android-webview tags)?

1
  • did you found any soultion.? facing the same issue. Commented Dec 18, 2020 at 6:05

1 Answer 1

1

try changing the userAgent of https://pub.dev/packages/flutter_webview_plugin for a chrome one , you can find them here

Future<Null> launch(String url, {
   bool withJavascript: true,
   String userAgent : 'Mozilla/5.0 (Linux; <Android Version>; <Build Tag etc.>) AppleWebKit/<WebKit Rev> (KHTML, like Gecko) Chrome/<Chrome Rev> Mobile Safari/<WebKit Rev>'
});
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks, @ValdaXD; I look forward to trying this. Keeping in mind my newbie-ness, will I need some sort of conditional code if I someday compile for a tablet or iOS device, or will the one userAgent string work well everywhere?
Yeah, the User Agent string is accepted by the webpage and the webpage doesn't even try to tell if it is right , try checking the articles about this , like howtogeek.com/114937/htg-explains-whats-a-browser-user-agent , it should work on Ios, android, an obviously web browsers
Sadly for me, the page displayed the same way. But +1 for the clarity and completeness of your response. I appreciate the link(s).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.