Skip to content

Commit

Permalink
fix position in wavy animation
Browse files Browse the repository at this point in the history
  • Loading branch information
SirusCodes committed Apr 23, 2021
1 parent 0a4c2c3 commit 73b14e4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 deletions.

This file was deleted.

20 changes: 16 additions & 4 deletions lib/src/wavy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,22 @@ class WavyAnimatedText extends AnimatedText {

@override
Widget animatedBuilder(BuildContext context, Widget? child) {
final defaultTextStyle = DefaultTextStyle.of(context).style;
final scaleFactor = MediaQuery.of(context).textScaleFactor;
return RepaintBoundary(
child: CustomPaint(
size: MediaQuery.of(context).size,
foregroundPainter: _WTextPainter(
painter: _WTextPainter(
progress: _waveAnim.value,
text: text,
textStyle: DefaultTextStyle.of(context).style.merge(textStyle),
textStyle: defaultTextStyle.merge(textStyle),
scaleFactor: scaleFactor,
),
child: Text(
text,
style: defaultTextStyle
.merge(textStyle)
.merge(TextStyle(color: Colors.transparent)),
textScaleFactor: scaleFactor,
),
),
);
Expand Down Expand Up @@ -105,9 +114,10 @@ class _WTextPainter extends CustomPainter {
required this.progress,
required this.text,
required this.textStyle,
required this.scaleFactor,
});

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

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

textPainter.layout();
Expand Down

0 comments on commit 73b14e4

Please sign in to comment.