Skip to content

Ignore textScaleFactor deprecation #4209

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
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
3 changes: 2 additions & 1 deletion packages/flutter_markdown/lib/src/_functions_io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ final MarkdownStyleSheet Function(BuildContext, MarkdownStyleSheetBaseTheme?)
}

return result.copyWith(
textScaleFactor: MediaQuery.textScaleFactorOf(context),
textScaleFactor:
MediaQuery.textScaleFactorOf(context), // ignore: deprecated_member_use
);
};

Expand Down
3 changes: 2 additions & 1 deletion packages/flutter_markdown/lib/src/_functions_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ final MarkdownStyleSheet Function(BuildContext, MarkdownStyleSheetBaseTheme?)
}

return result.copyWith(
textScaleFactor: MediaQuery.textScaleFactorOf(context),
textScaleFactor:
MediaQuery.textScaleFactorOf(context), // ignore: deprecated_member_use
);
};

Expand Down
6 changes: 4 additions & 2 deletions packages/flutter_markdown/lib/src/builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -829,15 +829,17 @@ class MarkdownBuilder implements md.NodeVisitor {
if (selectable) {
return SelectableText.rich(
text!,
textScaleFactor: styleSheet.textScaleFactor,
textScaleFactor:
styleSheet.textScaleFactor, // ignore: deprecated_member_use
textAlign: textAlign ?? TextAlign.start,
onTap: onTapText,
key: k,
);
} else {
return RichText(
text: text!,
textScaleFactor: styleSheet.textScaleFactor!,
textScaleFactor:
styleSheet.textScaleFactor!, // ignore: deprecated_member_use
textAlign: textAlign ?? TextAlign.start,
key: k,
);
Expand Down
13 changes: 8 additions & 5 deletions packages/flutter_markdown/test/text_scale_factor_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void defineTests() {
);

final RichText richText = tester.widget(find.byType(RichText));
expect(richText.textScaleFactor, 2.0);
expect(richText.textScaleFactor, 2.0); // ignore: deprecated_member_use
},
);

Expand All @@ -36,7 +36,8 @@ void defineTests() {
await tester.pumpWidget(
boilerplate(
const MediaQuery(
data: MediaQueryData(textScaleFactor: 2.0),
data: MediaQueryData(
textScaleFactor: 2.0), // ignore: deprecated_member_use
child: MarkdownBody(
data: data,
),
Expand All @@ -45,7 +46,7 @@ void defineTests() {
);

final RichText richText = tester.widget(find.byType(RichText));
expect(richText.textScaleFactor, 2.0);
expect(richText.textScaleFactor, 2.0); // ignore: deprecated_member_use
},
);

Expand All @@ -56,7 +57,8 @@ void defineTests() {
await tester.pumpWidget(
boilerplate(
const MediaQuery(
data: MediaQueryData(textScaleFactor: 2.0),
data: MediaQueryData(
textScaleFactor: 2.0), // ignore: deprecated_member_use
child: MarkdownBody(
data: data,
selectable: true,
Expand All @@ -67,7 +69,8 @@ void defineTests() {

final SelectableText selectableText =
tester.widget(find.byType(SelectableText));
expect(selectableText.textScaleFactor, 2.0);
expect(selectableText.textScaleFactor,
2.0); // ignore: deprecated_member_use
},
);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/rfw/lib/src/flutter/core_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ Map<String, LocalWidgetBuilder> get _coreWidgetsDefinitions => <String, LocalWid
locale: ArgumentDecoders.locale(source, ['locale']),
softWrap: source.v<bool>(['softWrap']),
overflow: ArgumentDecoders.enumValue<TextOverflow>(TextOverflow.values, source, ['overflow']),
textScaleFactor: source.v<double>(['textScaleFactor']),
textScaleFactor: source.v<double>(['textScaleFactor']), // ignore: deprecated_member_use
Copy link
Contributor Author

@LongCatIsLooong LongCatIsLooong Jun 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how this is going to be migrated, since textScaler is essentially a function?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would something like textScaler: TextScaler.linear(source.v<double>(['textScaleFactor'])) work?

maxLines: source.v<int>(['maxLines']),
semanticsLabel: source.v<String>(['semanticsLabel']),
textWidthBasis: ArgumentDecoders.enumValue<TextWidthBasis>(TextWidthBasis.values, source, ['textWidthBasis']),
Expand Down