Skip to content

Commit

Permalink
refactor: replace scaleFactor with textScaler for improved text scali…
Browse files Browse the repository at this point in the history
…ng. otherwise GitHub CI won't accept the pr.
  • Loading branch information
oriventi committed Dec 29, 2024
1 parent 1c81535 commit e7fa3a2
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/src/wavy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,21 @@ class WavyAnimatedText extends AnimatedText {
@override
Widget animatedBuilder(BuildContext context, Widget? child) {
final defaultTextStyle = DefaultTextStyle.of(context).style;
final scaleFactor = MediaQuery.of(context).textScaleFactor;
final textScaler = MediaQuery.textScalerOf(context);
return RepaintBoundary(
child: CustomPaint(
painter: _WTextPainter(
progress: _waveAnim.value,
text: text,
textStyle: defaultTextStyle.merge(textStyle),
scaleFactor: scaleFactor,
textScaler: textScaler,
),
child: Text(
text,
style: defaultTextStyle
.merge(textStyle)
.merge(TextStyle(color: Colors.transparent)),
textScaleFactor: scaleFactor,
textScaler: textScaler,
),
),
);
Expand Down Expand Up @@ -114,10 +114,11 @@ class _WTextPainter extends CustomPainter {
required this.progress,
required this.text,
required this.textStyle,
required this.scaleFactor,
required this.textScaler,
});

final double progress, scaleFactor;
final double progress;
final TextScaler textScaler;
final String text;
// Private class to store text information
final _textLayoutInfo = <_TextLayoutInfo>[];
Expand Down Expand Up @@ -204,7 +205,7 @@ class _WTextPainter extends CustomPainter {
style: textStyle,
),
textDirection: TextDirection.ltr,
textScaleFactor: scaleFactor,
textScaler: textScaler,
)..layout();

textPainter.paint(
Expand All @@ -227,7 +228,7 @@ class _WTextPainter extends CustomPainter {
),
textDirection: TextDirection.ltr,
maxLines: 1,
textScaleFactor: scaleFactor,
textScaler: textScaler,
);

textPainter.layout();
Expand Down

0 comments on commit e7fa3a2

Please sign in to comment.