From 13da3802357365f5ee57ac92b8e68d7e92746fb5 Mon Sep 17 00:00:00 2001 From: Aayush Malhotra Date: Mon, 18 May 2020 14:57:28 +0530 Subject: [PATCH] Issue #58 resolved (#74) * Rotating text : add animation objects and controller * Rotating text : add text widgets * Rotating text : nested text widgets with animation builder * Rotating text : working * Typer : removed addlisteners for animations * Rotating text : removed animation listeners and code cleanup * Typewriter : partially working code * Typewriter : working * Typewriter : added default parameter for duration and made text @required for all * refractor names * Fade : working * Colorizer : gradient text made * Typewriter : dart analuysis error removed * Colorizer : working * Colorizer : updated ui * Colorizer : refrator name * Colorize : added tuning parameter * Colorize : made text string to list and added fade animation * Colorize : added default value of duration * fixed some ui * Typewriter : added default value of duration * Typewriter : added else value of duration * Colorize : added default value of duration * Fade : added default value of duration * Rotate : added default value of duration and added a new parameter transition height and added its default value * Typer : added default value of duration * Rotate : change slide curve to linear * fade : change fade curve to linear * Scale : working * Scale : added scaling parameter * Made basic example app ui * Added fonts * made theme for typer and typewriter * made theme for rest animated texts * showcase completed * added cover widget * fixed play button alignment * Typer : updated default value of duration * added labels for animations in ui * added smoke test {not working} * fixed testing errors * Updated LICENSE * added example app testing in travis.yaml * added preview gifs * fixed formatting issues * initial release 1.0.1 * Updated README.md * updated flutter version compatibility * fixed flutter compatibility issues * Added CODE_OF_CONDUCT.md * Update issue templates * Added contributing.md and updated readme * Added pull request template * Updated readme and contributions.md * Updated version to 1.0.2 * added table of contents to readme * Updated pull request section in contributing.md * Update travis.yaml and contributing.md * Remove travis build errors * :art: fix formating in test file * :tada: update version to 1.0.3 * :arrow_up: added onTap event for all text animations * :arrow_up: updated example * :bug: changed InkWell widget to GestureDetector for the onTap event * :fire: fixed formatting issues * :bug: fixed dart analysis issues * :tada: updated to version 1.1.0 * :green_heart: added some animations for the roadmap * :bug: fixed formatting issues * add .idea to .gitignore * Expand .gitignore, Add flag for running animation once, update gradle. * :bug: fixed fading with isRepeatingAnimation is set false * :memo: added isRepeatingAnimation to Readme * :tada: updated version to 1.2.0 * Added alignment property to Stack and textAlign property to Text * Added GenericAnimatedTextKit to simplify some initialization Added some common assertions * Revert "Added GenericAnimatedTextKit to simplify some initialization" This reverts commit 1dc30cc296aabd5ac07867346e805b01eb6f8168. * Updated README.md. Added the usage of "textAlign" and "alignment" properties * :bug: fixed opacity value in typer * :tada: updated to 1.3.0 * Updated Readme * docs: added documentation for the various parameters of all the animated text widgets * docs: updated example app readme * conf: updated travis script * conf: updated package to version 1.3.1 * conf: create funding.yml * docs: updated docs for duration parameter * docs: updated contributing.md * bfix: fixed travis * conf: added codecov coverage * docs: add salihgueler as a contributor (#36) * docs: update README.md * docs: create .all-contributorsrc * docs: updated readme * docs: add anderscheow as a contributor (#37) * docs: update README.md * docs: update .all-contributorsrc * docs: add r1walz as a contributor (#38) * docs: update README.md * docs: update .all-contributorsrc * Enhanced different classes of AnimatedTextKit * Fixed travis issue * Typer Class Enhancments (#40) * Typer Class Enhancments Refer to issue #34 The Typer Class has been greatly improved in term of control. ### Let's start with breaking changes : ####The duration parameter has become two new ones : speed and pause * speed is the elapsed time between the animation of each characters of a text (Default is 40 ms) * pause is the pause duration between texts (Default is 500 ms) ### New features : ####Three new callbacks come alongside the onTap : * onNext(int index, bool isLast) - This callback will be called before the next text animation, after the previous one's pause. * onNextBeforePause(int index, bool isLast) - This callback will be called before the next text animation, before the previous one's pause. * onFinished - This callback is called at the end, if the parameter isRepeatingAnimation is set to false ####Two new arguments : * displayFullTextOnTap - If true, tapping the screen will stop current animated text, and display it fully for min(remaining, pause) time. (Default is false) * stopPauseOnTap - If true, tapping during a pause will stop it and start the next text animation (Default is false) ####The text list parameter now accept either strings, or map where you can give a text custom speed and pause. If you like thoses changes, I'll make another commit with updated readme regarding this PR with code examples. * Fix indentation issues for Travis * Fix indentation issues for Travis * Fix formating issue in travis * chor: deleted flutter_export_environment.sh file (unnecessary) * Addeed TextLiquidFill animation to AnimatedTextKit * chor: fixed formatting issues * bfix: fixed Travis fail * conf: updated to version 2.0.0 * chor: updated readme * docs: add AdamSGit as a contributor (#49) * docs: update README.md [skip ci] * docs: update .all-contributorsrc [skip ci] * docs: add hemilpanchiwala as a contributor (#50) * docs: update README.md [skip ci] * docs: update .all-contributorsrc [skip ci] * docs: added text liquid fill medium blog link in Readme * feat: updated to v2.0.1 (#67) * #44 fix * added gitignore * gitignore * Issue 58 * Changed back to default example Co-authored-by: aagarwal1012 Co-authored-by: r1walz Co-authored-by: Muhammed Salih Guler Co-authored-by: Anders Cheow Co-authored-by: Anders Cheow Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> Co-authored-by: Hemil Panchiwala Co-authored-by: AdamSGit --- lib/src/colorize.dart | 8 +++----- lib/src/fade.dart | 16 ++++++---------- lib/src/rotate.dart | 13 +++++-------- lib/src/scale.dart | 8 ++------ lib/src/text_liquid_fill.dart | 14 ++++---------- lib/src/typer.dart | 12 ++++-------- lib/src/typewriter.dart | 13 ++++--------- 7 files changed, 28 insertions(+), 56 deletions(-) diff --git a/lib/src/colorize.dart b/lib/src/colorize.dart index e6a4127..4ed0cdf 100644 --- a/lib/src/colorize.dart +++ b/lib/src/colorize.dart @@ -141,7 +141,7 @@ class _RotatingTextState extends State @override void dispose() { - _controller.dispose(); + _controller?.dispose(); super.dispose(); } @@ -204,9 +204,7 @@ class _RotatingTextState extends State _index++; } - if (_controller != null) _controller.dispose(); - - setState(() {}); + if (mounted) setState(() {}); _controller = new AnimationController( duration: _texts[_index]['speed'] * _texts[_index]['text'].length, @@ -231,7 +229,7 @@ class _RotatingTextState extends State curve: Interval(0.0, 1.0, curve: Curves.easeIn))) ..addStatusListener(_animationEndCallback); - _controller.forward(); + _controller?.forward(); } void _animationEndCallback(state) { diff --git a/lib/src/fade.dart b/lib/src/fade.dart index fce864e..6086e00 100644 --- a/lib/src/fade.dart +++ b/lib/src/fade.dart @@ -149,15 +149,13 @@ class _RotatingTextState extends State _texts.add({'text': widget.text[i], 'pause': _pause}); } } - _nextAnimation(); } @override void dispose() { - _controller - ..stop() - ..dispose(); + _controller?.stop(); + _controller.dispose(); super.dispose(); } @@ -214,9 +212,7 @@ class _RotatingTextState extends State _index++; } - if (_controller != null) _controller.dispose(); - - setState(() {}); + if (mounted) setState(() {}); _controller = new AnimationController( duration: _duration, @@ -230,14 +226,14 @@ class _RotatingTextState extends State parent: _controller, curve: Interval(0.8, 1.0, curve: Curves.linear))) ..addStatusListener(_animationEndCallback); - _controller..forward(); + _controller.forward(); } void _setPause() { bool isLast = _index == widget.text.length - 1; _isCurrentlyPausing = true; - setState(() {}); + if (mounted) setState(() {}); // Handle onNextBeforePause callback if (widget.onNextBeforePause != null) @@ -265,7 +261,7 @@ class _RotatingTextState extends State pause = _texts[_index]['pause'].inMilliseconds; left = widget.duration.inMilliseconds; - _controller.stop(); + _controller?.stop(); _setPause(); diff --git a/lib/src/rotate.dart b/lib/src/rotate.dart index 071c39c..6d8bbe6 100644 --- a/lib/src/rotate.dart +++ b/lib/src/rotate.dart @@ -157,9 +157,8 @@ class _RotatingTextState extends State @override void dispose() { - _controller - ..stop() - ..dispose(); + _controller?.stop(); + _controller?.dispose(); super.dispose(); } @@ -222,9 +221,7 @@ class _RotatingTextState extends State _index++; } - if (_controller != null) _controller.dispose(); - - setState(() {}); + if (mounted) setState(() {}); if (widget.transitionHeight == null) { _transitionHeight = widget.textStyle.fontSize * 10 / 3; @@ -278,7 +275,7 @@ class _RotatingTextState extends State bool isLast = _index == widget.text.length - 1; _isCurrentlyPausing = true; - setState(() {}); + if (mounted) setState(() {}); // Handle onNextBeforePause callback if (widget.onNextBeforePause != null) @@ -301,7 +298,7 @@ class _RotatingTextState extends State } else { pause = _texts[_index]['pause'].inMilliseconds; - _controller.stop(); + _controller?.stop(); _setPause(); diff --git a/lib/src/scale.dart b/lib/src/scale.dart index 8b979e7..53befd2 100644 --- a/lib/src/scale.dart +++ b/lib/src/scale.dart @@ -162,10 +162,8 @@ class _RotatingTextState extends State @override void dispose() { - if (_controller != null) - _controller - ..stop() - ..dispose(); + _controller?.stop(); + _controller?.dispose(); super.dispose(); } @@ -225,8 +223,6 @@ class _RotatingTextState extends State _index++; } - if (_controller != null) _controller.dispose(); - setState(() {}); _controller = new AnimationController( diff --git a/lib/src/text_liquid_fill.dart b/lib/src/text_liquid_fill.dart index 0076b1f..66a8c99 100644 --- a/lib/src/text_liquid_fill.dart +++ b/lib/src/text_liquid_fill.dart @@ -101,16 +101,10 @@ class _TextLiquidFillState extends State @override void dispose() { - if (_waveController != null) - _waveController - ..stop() - ..dispose(); - - if (_loadController != null) - _loadController - ..stop() - ..dispose(); - + _waveController?.stop(); + _waveController?.dispose(); + _loadController?.stop(); + _loadController?.dispose(); super.dispose(); } diff --git a/lib/src/typer.dart b/lib/src/typer.dart index 78651e6..ecd491f 100644 --- a/lib/src/typer.dart +++ b/lib/src/typer.dart @@ -133,10 +133,8 @@ class _TyperState extends State @override void dispose() { - if (_controller != null) - _controller - ..stop() - ..dispose(); + _controller?.stop(); + _controller?.dispose(); super.dispose(); } @@ -187,9 +185,7 @@ class _TyperState extends State _index++; } - if (_controller != null) _controller.dispose(); - - setState(() {}); + if (mounted) setState(() {}); _controller = new AnimationController( duration: _texts[_index]['speed'] * _texts[_index]['text'].length, @@ -207,7 +203,7 @@ class _TyperState extends State bool isLast = _index == widget.text.length - 1; _isCurrentlyPausing = true; - setState(() {}); + if (mounted) setState(() {}); // Handle onNextBeforePause callback if (widget.onNextBeforePause != null) diff --git a/lib/src/typewriter.dart b/lib/src/typewriter.dart index e0c4407..7770b85 100644 --- a/lib/src/typewriter.dart +++ b/lib/src/typewriter.dart @@ -151,11 +151,8 @@ class _TypewriterState extends State @override void dispose() { - if (_controller != null) { - _controller - ..stop() - ..dispose(); - } + _controller?.stop(); + _controller?.dispose(); super.dispose(); } @@ -229,9 +226,7 @@ class _TypewriterState extends State _index++; } - if (_controller != null) _controller.dispose(); - - setState(() {}); + if (mounted) setState(() {}); _controller = new AnimationController( duration: _texts[_index]['speed'] * _texts[_index]['text'].length, @@ -250,7 +245,7 @@ class _TypewriterState extends State bool isLast = _index == widget.text.length - 1; _isCurrentlyPausing = true; - setState(() {}); + if (mounted) setState(() {}); // Handle onNextBeforePause callback if (widget.onNextBeforePause != null)