diff --git a/lib/custom_render.dart b/lib/custom_render.dart index 88e983935d..68298138fd 100644 --- a/lib/custom_render.dart +++ b/lib/custom_render.dart @@ -536,7 +536,7 @@ double _aspectRatio( if (heightString != null && widthString != null) { final height = double.tryParse(heightString); final width = double.tryParse(widthString); - return height == null || width == null || height == 0.0 + return height == null || width == null || height == 0.0 ? calculated.data!.aspectRatio : width / height; } diff --git a/lib/flutter_html.dart b/lib/flutter_html.dart index 5e3f1cd460..e4dc0e992a 100644 --- a/lib/flutter_html.dart +++ b/lib/flutter_html.dart @@ -344,6 +344,7 @@ class _SelectableHtmlState extends State { ? HtmlParser.parseHTML(widget.data!) : widget.documentElement!; } + @override void didUpdateWidget(SelectableHtml oldWidget) { super.didUpdateWidget(oldWidget); diff --git a/lib/html_parser.dart b/lib/html_parser.dart index e10d8efa3d..31271ea0d9 100644 --- a/lib/html_parser.dart +++ b/lib/html_parser.dart @@ -104,6 +104,7 @@ class HtmlParser extends StatelessWidget { scrollPhysics: scrollPhysics, selectionControls: selectionControls, shrinkWrap: shrinkWrap, + top: true, ); } diff --git a/lib/src/css_box_widget.dart b/lib/src/css_box_widget.dart index 20843fdd8d..d95450eecb 100644 --- a/lib/src/css_box_widget.dart +++ b/lib/src/css_box_widget.dart @@ -12,6 +12,7 @@ class CssBoxWidget extends StatelessWidget { this.textDirection, this.childIsReplaced = false, this.shrinkWrap = false, + this.top = false, }); /// Generates a CSSBoxWidget that contains a list of InlineSpan children. @@ -23,6 +24,7 @@ class CssBoxWidget extends StatelessWidget { this.childIsReplaced = false, this.shrinkWrap = false, bool selectable = false, + this.top = false, TextSelectionControls? selectionControls, ScrollPhysics? scrollPhysics, }) : child = selectable @@ -55,6 +57,9 @@ class CssBoxWidget extends StatelessWidget { /// necessarily take up the full available width unless necessary final bool shrinkWrap; + /// For the root widget, so textScaleFactor etc are only applied once + final bool top; + @override Widget build(BuildContext context) { final markerBox = style.listStylePosition == ListStylePosition.outside @@ -74,14 +79,18 @@ class CssBoxWidget extends StatelessWidget { shrinkWrap: shrinkWrap, children: [ Container( - decoration: BoxDecoration( - border: style.border, - color: style.backgroundColor, //Colors the padding and content boxes - ), - width: _shouldExpandToFillBlock() ? double.infinity : null, - padding: style.padding ?? EdgeInsets.zero, - child: child, - ), + decoration: BoxDecoration( + border: style.border, + color: + style.backgroundColor, //Colors the padding and content boxes + ), + width: _shouldExpandToFillBlock() ? double.infinity : null, + padding: style.padding ?? EdgeInsets.zero, + child: top + ? child + : MediaQuery( + data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0), + child: child)), if (markerBox != null) Text.rich(markerBox), ], ); @@ -103,8 +112,8 @@ class CssBoxWidget extends StatelessWidget { } } - return RichText( - text: TextSpan( + return Text.rich( + TextSpan( style: style.generateTextStyle(), children: children, ),