sdk: webview_flutter: ^3.0.0
https下官方没有提供http混合访问的接口, 只能强行实现.
- 将 webview_flutter_android库拷贝到本地
- 修改文件 WebSettingsHostApiImpl.java
@Override
public void create(Long instanceId, Long webViewInstanceId) {
final WebView webView = (WebView) instanceManager.getInstance(webViewInstanceId);
instanceManager.addInstance(webSettingsCreator.createWebSettings(webView), instanceId);
/// 添加如下代码
final WebSettings webSettings = (WebSettings) instanceManager.getInstance(instanceId);
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}
- 添加本地依赖
dependency_overrides:
# 官方库不允许http访问
webview_flutter_android:
path: '../webview_flutter_android-2.8.0'