From cf980c935a7457799bb6390562b303752e8c8c58 Mon Sep 17 00:00:00 2001 From: Zulfequar Ali Date: Thu, 30 Nov 2023 15:21:27 +0530 Subject: [PATCH 1/3] Move the entire if statement from the initState method to the build method Modify the code so that animations are handled (controlled) everytime a badge widget's build method is called. * If the showBadge property of a badge is true: Run the animations * If the showBadge property of a badge is false: Stop the animations --- lib/src/badge.dart | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/src/badge.dart b/lib/src/badge.dart index 7a13e8b..47bf9b7 100644 --- a/lib/src/badge.dart +++ b/lib/src/badge.dart @@ -83,7 +83,10 @@ class BadgeState extends State with TickerProviderStateMixin { parent: _animationController, curve: widget.badgeAnimation.curve, ); + } + @override + Widget build(BuildContext context) { if (widget.showBadge && widget.badgeAnimation.toAnimate) { _animationController.forward(); _appearanceController.forward(); @@ -94,11 +97,11 @@ class BadgeState extends State with TickerProviderStateMixin { reverse: true, ); } + } else { + _animationController.reset(); + _appearanceController.reset(); } - } - @override - Widget build(BuildContext context) { if (widget.child == null) { return widget.ignorePointer ? IgnorePointer(child: _getBadge()) From a85a5fe4a3b94eb9761b25c6b5ac962031cde5ee Mon Sep 17 00:00:00 2001 From: Zulfequar Ali Date: Thu, 30 Nov 2023 16:22:05 +0530 Subject: [PATCH 2/3] Initialize the badge's appearanceDisappearanceFadeAnimationEnabled field to false The commit cf980c9 fixes the intended issue for all types of animations (BadgeAnimation.slide, BadgeAnimation.scale, BadgeAnimation.rotate etc.) but once the showBadge field is set to true after setting it to false, the badge is shown back but its animation stops. Initializing the badge's appearanceDisappearanceFadeAnimationEnabled field to false fixes this issue. The code in this commit and in the commit cf980c9 has been tested on Android and Web and works fine on both the platforms and I expect that it should work fine on all the other platforms. --- lib/src/badge_animation.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/badge_animation.dart b/lib/src/badge_animation.dart index 211c185..56aff13 100644 --- a/lib/src/badge_animation.dart +++ b/lib/src/badge_animation.dart @@ -138,7 +138,7 @@ class BadgeAnimation { this.curve = Curves.easeOutCubic, this.colorChangeAnimationCurve = Curves.linear, this.colorChangeAnimationDuration = Duration.zero, - this.appearanceDisappearanceFadeAnimationEnabled = true, + this.appearanceDisappearanceFadeAnimationEnabled = false, }) : animationType = BadgeAnimationType.scale, sizeTransitionAxis = null, sizeTransitionAxisAlignment = null, From 59c2b23573f768c9c9288c447872ba8069d2a05e Mon Sep 17 00:00:00 2001 From: Zulfequar Ali Date: Thu, 30 Nov 2023 16:32:01 +0530 Subject: [PATCH 3/3] Correct the spelling Update word from Yheme to Theme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 00ac902..fc5ee36 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,6 @@ From left to right:
[Diagonal decoration](https://pub.dev/packages/diagonal_decoration) -[Yako Yheme Switch](https://pub.dev/packages/yako_theme_switch) +[Yako Theme Switch](https://pub.dev/packages/yako_theme_switch) and more to come! \ No newline at end of file