Skip to content

Commit 15cb05e

Browse files
committed
fix: Corrected accessibility text scaling
2 parents 1715cdc + 6a83e45 commit 15cb05e

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

lib/src/css_box_widget.dart

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class CssBoxWidget extends StatelessWidget {
1212
this.textDirection,
1313
this.childIsReplaced = false,
1414
this.shrinkWrap = false,
15+
this.top = false,
1516
});
1617

1718
/// Generates a CSSBoxWidget that contains a list of InlineSpan children.
@@ -22,6 +23,7 @@ class CssBoxWidget extends StatelessWidget {
2223
this.textDirection,
2324
this.childIsReplaced = false,
2425
this.shrinkWrap = false,
26+
this.top = false,
2527
}) : child = _generateWidgetChild(children, style);
2628

2729
/// The child to be rendered within the CSS Box.
@@ -45,6 +47,9 @@ class CssBoxWidget extends StatelessWidget {
4547
/// necessarily take up the full available width unless necessary
4648
final bool shrinkWrap;
4749

50+
/// For the root widget, so textScaleFactor, etc are only applied once
51+
final bool top;
52+
4853
@override
4954
Widget build(BuildContext context) {
5055
final markerBox = style.listStylePosition == ListStylePosition.outside
@@ -70,7 +75,12 @@ class CssBoxWidget extends StatelessWidget {
7075
),
7176
width: _shouldExpandToFillBlock() ? double.infinity : null,
7277
padding: style.padding ?? EdgeInsets.zero,
73-
child: child,
78+
child: top
79+
? child
80+
: MediaQuery(
81+
data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
82+
child: child,
83+
),
7484
),
7585
if (markerBox != null) Text.rich(markerBox),
7686
],
@@ -93,8 +103,8 @@ class CssBoxWidget extends StatelessWidget {
93103
}
94104
}
95105

96-
return RichText(
97-
text: TextSpan(
106+
return Text.rich(
107+
TextSpan(
98108
style: style.generateTextStyle(),
99109
children: children,
100110
),

lib/src/html_parser.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ class _HtmlParserState extends State<HtmlParser> {
181181
//TODO can we have buildTree return a list of InlineSpans rather than a single one.
182182
children: [buildTree()],
183183
shrinkWrap: widget.shrinkWrap,
184+
top: true,
184185
);
185186
}
186187

0 commit comments

Comments
 (0)