flutter中使用webview,用了 flutter_inappbrowser 這個(gè)庫(kù),Android端顯示正常,iOS出不來(lái),最初網(wǎng)上找大多數(shù)都是說(shuō)是因?yàn)闆]有添加對(duì)http請(qǐng)求的信任,需要在info里面添加
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
但是試過(guò)之后沒有,后來(lái)一陣折騰,在官方庫(kù)的文檔中找到
- InAppWebView: Flutter Widget for adding an inline native WebView integrated into the flutter widget tree. To use
InAppWebViewclass on iOS you need to opt-in for the embedded views preview by adding a boolean property to the app'sInfo.plistfile, with the keyio.flutter.embedded_views_previewand the valueYES.
就是說(shuō)在info添加 io.flutter.embedded_views_preview為 true 就行了
<plist version="1.0">
<dict>
...
<key>io.flutter.embedded_views_preview</key>
<true/>
</dict>
</plist>
使用各種類庫(kù)之前先看認(rèn)真文檔、說(shuō)明很重要。