解决华为 webview Chrome 78 内核版本渲染白屏问题
This commit is contained in:
@@ -64,7 +64,7 @@ class WebviewPageState extends State<WebviewPage> {
|
||||
late final WebViewController controller;
|
||||
controller = WebViewController.fromPlatformCreationParams(params)
|
||||
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||
..setBackgroundColor(Colors.transparent)
|
||||
..setBackgroundColor(Colors.white)
|
||||
..setNavigationDelegate(
|
||||
NavigationDelegate(
|
||||
onProgress: (int progress) {
|
||||
@@ -231,6 +231,21 @@ class WebviewPageState extends State<WebviewPage> {
|
||||
return const PlatformWebViewControllerCreationParams();
|
||||
}
|
||||
|
||||
Widget _buildWebView(WebViewController controller) {
|
||||
PlatformWebViewWidgetCreationParams params =
|
||||
PlatformWebViewWidgetCreationParams(controller: controller.platform);
|
||||
|
||||
if (WebViewPlatform.instance is AndroidWebViewPlatform) {
|
||||
params =
|
||||
AndroidWebViewWidgetCreationParams.fromPlatformWebViewWidgetCreationParams(
|
||||
params,
|
||||
displayWithHybridComposition: true,
|
||||
);
|
||||
}
|
||||
|
||||
return WebViewWidget.fromPlatformCreationParams(params: params);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -294,7 +309,7 @@ class WebviewPageState extends State<WebviewPage> {
|
||||
Expanded(
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned.fill(child: WebViewWidget(controller: controller)),
|
||||
Positioned.fill(child: _buildWebView(controller)),
|
||||
if (_isLoading)
|
||||
const Center(child: CircularProgressIndicator()),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user