Skip to content

Commit 79c834f

Browse files
committed
2 parents 757f9cf + 5a88676 commit 79c834f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/html_parser.dart

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,15 @@ class HtmlParser extends StatelessWidget {
6464
cleanedTree,
6565
);
6666

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+
);
6876
}
6977

7078
/// [parseHTML] converts a string of HTML to a DOM document using the dart `html` library.
@@ -703,10 +711,12 @@ class ContainerSpan extends StatelessWidget {
703711
class StyledText extends StatelessWidget {
704712
final InlineSpan textSpan;
705713
final Style style;
714+
final double textScaleFactor;
706715

707716
const StyledText({
708717
this.textSpan,
709718
this.style,
719+
this.textScaleFactor = 1.0,
710720
});
711721

712722
@override
@@ -721,6 +731,7 @@ class StyledText extends StatelessWidget {
721731
style: style.generateTextStyle(),
722732
textAlign: style.textAlign,
723733
textDirection: style.direction,
734+
textScaleFactor: textScaleFactor,
724735
),
725736
);
726737
}

0 commit comments

Comments
 (0)