Skip to content

Commit

Permalink
Showing the last text when finished repeating
Browse files Browse the repository at this point in the history
  • Loading branch information
guyluz11 committed Oct 18, 2024
1 parent bbca961 commit 886a38b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/src/animated_text.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:async';
import 'dart:math';

import 'package:flutter/material.dart';

/// Abstract base class for text animations.
Expand Down Expand Up @@ -140,6 +141,8 @@ class _AnimatedTextKitState extends State<AnimatedTextKit>

late AnimatedText _currentAnimatedText;

bool _isCompleted = false;

int _currentRepeatCount = 0;

int _index = 0;
Expand All @@ -164,6 +167,11 @@ class _AnimatedTextKitState extends State<AnimatedTextKit>
@override
Widget build(BuildContext context) {
final completeText = _currentAnimatedText.completeText(context);
if (_isCompleted) {
return widget.animatedTexts.last
.textWidget(widget.animatedTexts.last.text);
}

return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: _onTap,
Expand Down Expand Up @@ -196,6 +204,9 @@ class _AnimatedTextKitState extends State<AnimatedTextKit>
_currentRepeatCount++;
}
} else {
setState(() {
_isCompleted = true;
});
widget.onFinished?.call();
return;
}
Expand Down

0 comments on commit 886a38b

Please sign in to comment.