@@ -64,7 +64,15 @@ class HtmlParser extends StatelessWidget {
64
64
cleanedTree,
65
65
);
66
66
67
- return StyledText (textSpan: parsedTree, style: cleanedTree.style);
67
+ // This is the final scaling that assumes any other StyledText instances are
68
+ // using textScaleFactor = 1.0 (which is the default). This ensures the correct
69
+ // scaling is used, but relies on https://github.com/flutter/flutter/pull/59711
70
+ // to wrap everything when larger accessibility fonts are used.
71
+ return StyledText (
72
+ textSpan: parsedTree,
73
+ style: cleanedTree.style,
74
+ textScaleFactor: MediaQuery .of (context).textScaleFactor,
75
+ );
68
76
}
69
77
70
78
/// [parseHTML] converts a string of HTML to a DOM document using the dart `html` library.
@@ -703,10 +711,12 @@ class ContainerSpan extends StatelessWidget {
703
711
class StyledText extends StatelessWidget {
704
712
final InlineSpan textSpan;
705
713
final Style style;
714
+ final double textScaleFactor;
706
715
707
716
const StyledText ({
708
717
this .textSpan,
709
718
this .style,
719
+ this .textScaleFactor = 1.0 ,
710
720
});
711
721
712
722
@override
@@ -721,6 +731,7 @@ class StyledText extends StatelessWidget {
721
731
style: style.generateTextStyle (),
722
732
textAlign: style.textAlign,
723
733
textDirection: style.direction,
734
+ textScaleFactor: textScaleFactor,
724
735
),
725
736
);
726
737
}
0 commit comments