From 0ef1a15d9a9c4f25906a1f67fb3e6c76be4b2865 Mon Sep 17 00:00:00 2001 From: dab246 Date: Wed, 7 Sep 2022 18:12:56 +0700 Subject: [PATCH] TF-884 Set max height for WebView is device physical size height on Android --- .../views/html_viewer/html_content_viewer_widget.dart | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/lib/presentation/views/html_viewer/html_content_viewer_widget.dart b/core/lib/presentation/views/html_viewer/html_content_viewer_widget.dart index 6bcf85cbf..31f4b3bc2 100644 --- a/core/lib/presentation/views/html_viewer/html_content_viewer_widget.dart +++ b/core/lib/presentation/views/html_viewer/html_content_viewer_widget.dart @@ -1,5 +1,6 @@ import 'dart:async'; import 'dart:io'; +import 'dart:ui'; import 'package:core/core.dart'; import 'package:flutter/cupertino.dart'; @@ -44,7 +45,7 @@ class _HtmlContentViewState extends State { late double actualHeight; double minHeight = 100; double minWidth = 300; - final double maxHeightForAndroid = 6000; + late double maxHeightForAndroid; String? _htmlData; late WebViewController _webViewController; bool _isLoading = true; @@ -53,6 +54,8 @@ class _HtmlContentViewState extends State { void initState() { super.initState(); actualHeight = widget.heightContent; + maxHeightForAndroid = window.physicalSize.height; + log('_HtmlContentViewState::initState(): maxHeightForAndroid: $maxHeightForAndroid'); _htmlData = _generateHtmlDocument(widget.contentHtml); } @@ -64,7 +67,6 @@ class _HtmlContentViewState extends State { @override Widget build(BuildContext context) { return LayoutBuilder(builder: (context, constraints) { - log('_HtmlContentViewState::build(): maxWidth: ${constraints.maxWidth}'); return Stack( children: [ SizedBox( @@ -109,7 +111,7 @@ class _HtmlContentViewState extends State { if (scrollHeightWithBuffer > minHeight) { setState(() { //TODO: It hotfix for web_view crash on android device and waiting lib web_view update to fix this issue - if(Platform.isAndroid && scrollHeightWithBuffer > maxHeightForAndroid){ + if (Platform.isAndroid && scrollHeightWithBuffer > maxHeightForAndroid){ actualHeight = maxHeightForAndroid; } else { actualHeight = scrollHeightWithBuffer;