Why webview_flutter not working in case of add to app (iOS)?

4,479

Solution 1

After a few hours of debugging I found that we need to add this key in the iOS project info.plist file rather than putting it into the info.plist in the iOS folder of the flutter module

<key>io.flutter.embedded_views_preview</key>
<true/>

Solution 2

Ive ran into this issue too when using webview_flutter. Fortunately, the ios setup from flutter_webview_plugin seemed to work. I used this tag in xcode's Info.list:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
    <key>NSAllowsArbitraryLoadsInWebContent</key>
    <true/>
</dict>

Please be mindful that they are currently merging to the official webview_flutter plugin.

Solution 3

If url you're using has some special character. So,You need to encode the URL like this,

 WebView(
      initialUrl: Uri.encodeFull(yourUrl),
      ...
 )
Share:
4,479
Let's_Create
Author by

Let's_Create

Updated on November 25, 2022

Comments

  • Let's_Create
    Let's_Create over 1 year

    So I am trying to open a simple webview when a button is clicked.

    This is the body of my Scaffold widget:

    body: 
    WebView(
        initialUrl: "https://www.google.com/",
        javascriptMode: JavascriptMode.unrestricted,
    )
    

    The interesting part is when I run this flutter project independently it successfully opens the Webview in the iOS simulator. But when I integrated this flutter module into an existing iOS App it doesn't work (Shows a blank screen). In order to add a flutter module, I have followed this link, the other part of the module works fine.

    I have already set this in the info.plist for the flutter module:

    <key>io.flutter.embedded_views_preview</key>
    <true/>
    

    I have added the following version in pubspec.yaml file:

    webview_flutter: ^0.3.22+1
    
    • Rudolf J
      Rudolf J about 2 years
      Have you found a solution for this yet?