diff --git a/README.md b/README.md index b18288a..e61aef7 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,7 @@ It has many configurable properties, including: - `isRepeatingAnimation` – controls whether the animation repeats - `repeatForever` – controls whether the animation repeats forever - `totalRepeatCount` – number of times the animation should repeat (when `repeatForever` is `false`) +- `overrideTexts` – it allows to show animated texts without override it (default is `true`) There are also custom callbacks: diff --git a/lib/src/animated_text.dart b/lib/src/animated_text.dart index db3f851..e8515b2 100644 --- a/lib/src/animated_text.dart +++ b/lib/src/animated_text.dart @@ -72,6 +72,9 @@ class AnimatedTextKit extends StatefulWidget { /// By default it is set to false. final bool displayFullTextOnTap; + ///Overrides previous text to other one. It's true by default + final bool overrideTexts; + /// If on pause, should a tap remove the remaining pause time ? /// /// By default it is set to false. @@ -117,6 +120,7 @@ class AnimatedTextKit extends StatefulWidget { this.pause = const Duration(milliseconds: 1000), this.displayFullTextOnTap = false, this.stopPauseOnTap = false, + this.overrideTexts = true, this.onTap, this.onNext, this.onNextBeforePause, @@ -163,22 +167,36 @@ class _AnimatedTextKitState extends State @override Widget build(BuildContext context) { - final completeText = _currentAnimatedText.completeText(context); return GestureDetector( behavior: HitTestBehavior.opaque, onTap: _onTap, - child: _isCurrentlyPausing || !_controller.isAnimating - ? completeText - : AnimatedBuilder( - animation: _controller, - builder: _currentAnimatedText.animatedBuilder, - child: completeText, + child: widget.overrideTexts + ? _animationRenderer() + : Column( + children: widget.animatedTexts + .take(_index) + .map((e) => Text( + e.text, + style: e.textStyle, + )) + .toList() + + [_animationRenderer()], ), ); } bool get _isLast => _index == widget.animatedTexts.length - 1; + Widget _animationRenderer() { + final completeText = _currentAnimatedText.completeText(context); + return _isCurrentlyPausing || !_controller.isAnimating + ? completeText + : AnimatedBuilder( + animation: _controller, + builder: _currentAnimatedText.animatedBuilder, + child: completeText); + } + void _nextAnimation() { final isLast = _isLast;