I use WebView to open a site, site is using responsive design.
On Android the site fills the page and work correctly Android Image
My Problem in IOS it appears as it open in desktop not in mobile mode IOS Image
I am a new in flutter but i solved this problem in Xamarin This the same Problem in xamarin
This is code Used to Open Web View by dart language in flutter
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(_title),
backgroundColor: dark_blue,
),
body: WebView(
initialUrl: _selectedUrl,
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController webViewController) {
_controller.complete(webViewController);
},
navigationDelegate: (NavigationRequest request) {
if (request.url.contains('https://helper')) {
CompletePaymentFun();
return NavigationDecision.prevent;
}
return NavigationDecision.navigate;
},
));}
this is my solution in c# I made a custom Webview in ios but I don't know how to solve it in flutter using dart language.
class CustomWebViewRenderer : WkWebViewRenderer
{
const string JavaScriptFunction = @"var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=device-width'); document.getElementsByTagName('head')[0].appendChild(meta);";
WKUserContentController userController;
public CustomWebViewRenderer() : this(new WKWebViewConfiguration())
{
}
public CustomWebViewRenderer(WKWebViewConfiguration config) : base(config)
{
userController = config.UserContentController;
var script = new WKUserScript(new NSString(JavaScriptFunction), WKUserScriptInjectionTime.AtDocumentEnd, false);
userController.AddUserScript(script);
config.UserContentController = userController;
WKWebView webView = new WKWebView(Frame, config);
}
}