From a4333d3bd1611cde1a8e33f57833b61f6a7c0eae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E9=94=8B?= <2535831261@qq.com> Date: Fri, 17 Jul 2026 15:22:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=8D=8E=E4=B8=BA=20webview?= =?UTF-8?q?=20Chrome=2078=20=E5=86=85=E6=A0=B8=E7=89=88=E6=9C=AC=E6=B8=B2?= =?UTF-8?q?=E6=9F=93=E7=99=BD=E5=B1=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/shared/widgets/app_webview.dart | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/shared/widgets/app_webview.dart b/lib/shared/widgets/app_webview.dart index 0090d09..3858528 100644 --- a/lib/shared/widgets/app_webview.dart +++ b/lib/shared/widgets/app_webview.dart @@ -64,7 +64,7 @@ class WebviewPageState extends State { 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 { 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 { Expanded( child: Stack( children: [ - Positioned.fill(child: WebViewWidget(controller: controller)), + Positioned.fill(child: _buildWebView(controller)), if (_isLoading) const Center(child: CircularProgressIndicator()), ],