TF-884 Set max height for WebView is device physical size height on Android
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:core/core.dart';
|
import 'package:core/core.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
@@ -44,7 +45,7 @@ class _HtmlContentViewState extends State<HtmlContentViewer> {
|
|||||||
late double actualHeight;
|
late double actualHeight;
|
||||||
double minHeight = 100;
|
double minHeight = 100;
|
||||||
double minWidth = 300;
|
double minWidth = 300;
|
||||||
final double maxHeightForAndroid = 6000;
|
late double maxHeightForAndroid;
|
||||||
String? _htmlData;
|
String? _htmlData;
|
||||||
late WebViewController _webViewController;
|
late WebViewController _webViewController;
|
||||||
bool _isLoading = true;
|
bool _isLoading = true;
|
||||||
@@ -53,6 +54,8 @@ class _HtmlContentViewState extends State<HtmlContentViewer> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
actualHeight = widget.heightContent;
|
actualHeight = widget.heightContent;
|
||||||
|
maxHeightForAndroid = window.physicalSize.height;
|
||||||
|
log('_HtmlContentViewState::initState(): maxHeightForAndroid: $maxHeightForAndroid');
|
||||||
_htmlData = _generateHtmlDocument(widget.contentHtml);
|
_htmlData = _generateHtmlDocument(widget.contentHtml);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +67,6 @@ class _HtmlContentViewState extends State<HtmlContentViewer> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return LayoutBuilder(builder: (context, constraints) {
|
return LayoutBuilder(builder: (context, constraints) {
|
||||||
log('_HtmlContentViewState::build(): maxWidth: ${constraints.maxWidth}');
|
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
SizedBox(
|
||||||
@@ -109,7 +111,7 @@ class _HtmlContentViewState extends State<HtmlContentViewer> {
|
|||||||
if (scrollHeightWithBuffer > minHeight) {
|
if (scrollHeightWithBuffer > minHeight) {
|
||||||
setState(() {
|
setState(() {
|
||||||
//TODO: It hotfix for web_view crash on android device and waiting lib web_view update to fix this issue
|
//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;
|
actualHeight = maxHeightForAndroid;
|
||||||
} else {
|
} else {
|
||||||
actualHeight = scrollHeightWithBuffer;
|
actualHeight = scrollHeightWithBuffer;
|
||||||
|
|||||||
Reference in New Issue
Block a user