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

Bug fix: Properly disposed of Timer for Rotate, Scale, and Typer. #123

Merged
merged 1 commit into from
Oct 12, 2020
Merged
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
3 changes: 3 additions & 0 deletions lib/src/rotate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class _RotatingTextState extends State<RotateAnimatedTextKit>

@override
void dispose() {
_timer?.cancel();
_controller?.stop();
_controller?.dispose();
super.dispose();
Expand Down Expand Up @@ -268,6 +269,7 @@ class _RotatingTextState extends State<RotateAnimatedTextKit>

void _animationEndCallback(state) {
if (state == AnimationStatus.completed) {
assert(null == _timer || !_timer.isActive);
_timer = Timer(_texts[_index]['pause'], _nextAnimation);
}
}
Expand All @@ -282,6 +284,7 @@ class _RotatingTextState extends State<RotateAnimatedTextKit>

_setPause();

assert(null == _timer || !_timer.isActive);
_timer = Timer(_texts[_index]['pause'], _nextAnimation);
}
}
Expand Down
3 changes: 3 additions & 0 deletions lib/src/scale.dart
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ class _ScaleTextState extends State<ScaleAnimatedTextKit>

@override
void dispose() {
_timer?.cancel();
_controller?.stop();
_controller?.dispose();
super.dispose();
Expand Down Expand Up @@ -255,6 +256,7 @@ class _ScaleTextState extends State<ScaleAnimatedTextKit>
void _animationEndCallback(state) {
if (state == AnimationStatus.completed) {
_isCurrentlyPausing = true;
assert(null == _timer || !_timer.isActive);
_timer = Timer(_texts[_index]['pause'], _nextAnimation);
}
}
Expand All @@ -274,6 +276,7 @@ class _ScaleTextState extends State<ScaleAnimatedTextKit>

_setPause();

assert(null == _timer || !_timer.isActive);
_timer =
Timer(Duration(milliseconds: max(pause, left)), _nextAnimation);
}
Expand Down
3 changes: 3 additions & 0 deletions lib/src/typer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class _TyperState extends State<TyperAnimatedTextKit>

@override
void dispose() {
_timer?.cancel();
_controller?.stop();
_controller?.dispose();
super.dispose();
Expand Down Expand Up @@ -207,6 +208,7 @@ class _TyperState extends State<TyperAnimatedTextKit>
void _animationEndCallback(state) {
if (state == AnimationStatus.completed) {
_setPause();
assert(null == _timer || !_timer.isActive);
_timer = Timer(_texts[_index]['pause'], _nextAnimation);
}
}
Expand All @@ -227,6 +229,7 @@ class _TyperState extends State<TyperAnimatedTextKit>

_setPause();

assert(null == _timer || !_timer.isActive);
_timer =
Timer(Duration(milliseconds: max(pause, left)), _nextAnimation);
}
Expand Down