Skip to content
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

Showing the last text when finished repeating #348

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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