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