Skip to content

Corrected accessibility text scaling #1259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/custom_render.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions lib/flutter_html.dart
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ class _SelectableHtmlState extends State<SelectableHtml> {
? HtmlParser.parseHTML(widget.data!)
: widget.documentElement!;
}

@override
void didUpdateWidget(SelectableHtml oldWidget) {
super.didUpdateWidget(oldWidget);
Expand Down
1 change: 1 addition & 0 deletions lib/html_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class HtmlParser extends StatelessWidget {
scrollPhysics: scrollPhysics,
selectionControls: selectionControls,
shrinkWrap: shrinkWrap,
top: true,
);
}

Expand Down
29 changes: 19 additions & 10 deletions lib/src/css_box_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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),
],
);
Expand All @@ -103,8 +112,8 @@ class CssBoxWidget extends StatelessWidget {
}
}

return RichText(
text: TextSpan(
return Text.rich(
TextSpan(
style: style.generateTextStyle(),
children: children,
),
Expand Down