flutter中使用webview,用了 flutter_inappbrowser
这个库,Android端显示正常,iOS出不来,最初网上找大多数都是说是因为没有添加对http请求的信任,需要在info里面添加
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
但是试过之后没有,后来一阵折腾,在官方库的文档中找到
- InAppWebView: Flutter Widget for adding an inline native WebView integrated into the flutter widget tree. To use
InAppWebView
class on iOS you need to opt-in for the embedded views preview by adding a boolean property to the app'sInfo.plist
file, with the keyio.flutter.embedded_views_preview
and the valueYES
.
就是说在info添加 io.flutter.embedded_views_preview
为 true
就行了
<plist version="1.0">
<dict>
...
<key>io.flutter.embedded_views_preview</key>
<true/>
</dict>
</plist>
使用各种类库之前先看认真文档、说明很重要。
网友评论