7

I working on webview in flutter . I cant able to open http url in IOS. It working on https. Can anyone suggest how to overcome this.

I put in info.plist

 <key>io.flutter.embedded_views_preview</key>
    <string>YES</string>
     <key>NSAllowsArbitraryLoads</key>
    <true/>

Regards, Sathish

4 Answers 4

18

Add this to your Info.plist

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

Apple Transport Security needs to be disabled.

  1. Open project in Xcode.
  2. Open Info.plist
  3. Add a new row to Information Property List (check id it's already there)

enter image description here

  1. Select App Transport Security Settings
  2. Make sure Allow Arbitrary Loads is set to YES
4
2

In case if your url has some special character. You need to encode the URL like this,

WebView(
      initialUrl: Uri.encodeFull(EnterUrlHere),
      ...
 )

1
  • this worked for me, after wasting so much time Aug 20 at 20:47
0

In iOS UIWebview is deprecated so your should your WKWebview.

For Flutter you should use below dependency :

webview_flutter: 0.3.15+1

Import this class :

import 'package:webview_flutter/webview_flutter.dart';

Add this widget :

@override
Widget build(BuildContext context) {
return Scaffold(
  appBar: new AppBar(
      title: Text(this.title,centerTitle: true
  ),
  body: WebView(
  initialUrl: url,
  onPageFinished:(value){
    setState(() {
      print("====your page is load");
    });
  },
  )
);
}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.