Flutter webview http url在IOS中不起作用

问题描述 投票:0回答:2

我在flutter中从事webview的工作。我无法在IOS中打开http网址。它在https上工作。谁能建议如何克服这个问题。

我放入info.plist

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

关于,沙语

flutter webview
2个回答
1
投票

需要禁用Apple Transport Security。

  1. 使用Xcode打开项目。
  2. 打开Info.plist
  3. Information Property List添加新行(检查ID是否已存在)

enter image description here

  1. 选择App Transport Security Settings
  2. 确保Allow Arbitrary Loads设置为YES

1
投票

不推荐使用iOS UIWebview,因此您应该使用WKWebview。

对于Flutter,您应该使用以下依赖项:

webview_flutter: 0.3.15+1

导入该课程:

import 'package:webview_flutter/webview_flutter.dart';

添加此小部件:

@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");
    });
  },
  )
);
}
© www.soinside.com 2019 - 2024. All rights reserved.