Skip to content
Open
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
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ AnimatedTextKit(
speed: const Duration(milliseconds: 2000),
),
],

totalRepeatCount: 4,
pause: const Duration(milliseconds: 1000),
displayFullTextOnTap: true,
Expand Down Expand Up @@ -409,6 +409,9 @@ return SizedBox(
fontWeight: FontWeight.bold,
),
boxHeight: 300.0,
onFinished: () {
print("Animation finished!");
},
),
);
```
Expand Down
3 changes: 3 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ List<AnimatedTextExample> animatedTextExamples({VoidCallback? onTap}) =>
fontWeight: FontWeight.bold,
),
boxHeight: 300,
onFinished: () {
//This is called at the animation end
},
),
),
AnimatedTextExample(
Expand Down
19 changes: 19 additions & 0 deletions lib/src/text_liquid_fill.dart

Choose a reason for hiding this comment

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

Can we make class TextLiquidFill extends AnimatedText,
so that we use this animation just like all other as a part of AnimatedTextKit

Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ class TextLiquidFill extends StatefulWidget {
/// By default, the animation will load to 1.0 (100%).
final double loadUntil;

/// Adds the onFinished [VoidCallback] to the animated widget.
final VoidCallback? onFinished;

TextLiquidFill({
Key? key,
required this.text,
Expand All @@ -68,6 +71,7 @@ class TextLiquidFill extends StatefulWidget {
this.boxBackgroundColor = Colors.black,
this.waveColor = Colors.blueAccent,
this.loadUntil = 1.0,
this.onFinished,
}) : assert(loadUntil > 0 && loadUntil <= 1.0),
super(key: key);

Expand Down Expand Up @@ -97,6 +101,19 @@ class _TextLiquidFillState extends State<TextLiquidFill>
vsync: this,
duration: widget.loadDuration,
);

//If exist, call onFisihed callback on animation end and remove listener.
if (widget.onFinished != null) {
late Callback statusListener;
statusListener = (status) {
if (status == AnimationStatus.completed) {
widget.onFinished?.call();
_loadController.removeStatusListener(statusListener);
}
};
_loadController.addStatusListener(statusListener);
}

_loadValue = Tween<double>(
begin: 0.0,
end: widget.loadUntil,
Expand Down Expand Up @@ -215,3 +232,5 @@ class _WavePainter extends CustomPainter {
return true;
}
}

typedef Callback = void Function(AnimationStatus);