From ad4aa20aeb0c8c9135316d984243b7fcfd27414b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tama=CC=81s=20Szabo=CC=81?= Date: Fri, 30 Apr 2021 21:22:13 +0200 Subject: [PATCH 1/6] BorderWidth null fix --- lib/button_stagger_animation.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/button_stagger_animation.dart b/lib/button_stagger_animation.dart index fd2f382..64b585a 100644 --- a/lib/button_stagger_animation.dart +++ b/lib/button_stagger_animation.dart @@ -87,9 +87,11 @@ class ButtonStaggerAnimation extends StatelessWidget { elevation: MaterialStateProperty.all(elevation), shape: MaterialStateProperty.all(RoundedRectangleBorder( borderRadius: borderRadiusAnimation.value, - side: BorderSide( + side: borderWidth!=null ? + BorderSide( color: borderColor ?? Color(0xffff5745), - width: borderWidth!), + width: borderWidth!) + : BorderSide.none, )), foregroundColor: MaterialStateProperty.all(color), ), From 8b4bc13c0bc1274ac16f274fb695bfe9ad33217d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tama=CC=81s=20Szabo=CC=81?= Date: Fri, 30 Apr 2021 21:22:27 +0200 Subject: [PATCH 2/6] Background color fix --- lib/button_stagger_animation.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/button_stagger_animation.dart b/lib/button_stagger_animation.dart index 64b585a..aaa1679 100644 --- a/lib/button_stagger_animation.dart +++ b/lib/button_stagger_animation.dart @@ -93,7 +93,8 @@ class ButtonStaggerAnimation extends StatelessWidget { width: borderWidth!) : BorderSide.none, )), - foregroundColor: MaterialStateProperty.all(color), + backgroundColor: MaterialStateProperty.all(color), + ), child: _buttonChild(), onPressed: () { @@ -104,4 +105,4 @@ class ButtonStaggerAnimation extends StatelessWidget { }, ); } -} +} \ No newline at end of file From a1f1ad4fb47014f262bca7fd491e4dde453f4c70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tama=CC=81s=20Szabo=CC=81?= Date: Fri, 30 Apr 2021 23:41:14 +0200 Subject: [PATCH 3/6] SpinnerButtonController --- lib/spinner_button.dart | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/lib/spinner_button.dart b/lib/spinner_button.dart index 29d4eb9..9d4cd14 100644 --- a/lib/spinner_button.dart +++ b/lib/spinner_button.dart @@ -4,6 +4,31 @@ import 'package:flutter/material.dart'; import 'button_stagger_animation.dart'; +class SpinnerButtonController{ + + final AnimationController animationController; + + SpinnerButtonController(this.animationController); + + bool _isInProgress=false; + + bool get isInProgress{ + return _isInProgress; + } + + void set isInProgress(bool isInProgress) { + _isInProgress=isInProgress; + + if(isInProgress){ + animationController.forward(); + }else{ + animationController.reverse(); + } + + } + +} + class SpinnerButton extends StatefulWidget { /// The background color of the button. final Color color; @@ -33,7 +58,7 @@ class SpinnerButton extends StatefulWidget { /// /// This will grant access to its [AnimationController] so /// that the animation can be controlled based on the need. - final Function(AnimationController? controller) onPressed; + final Function(SpinnerButtonController controller) onPressed; /// The child to display on the button. final Widget child; @@ -62,6 +87,7 @@ class SpinnerButton extends StatefulWidget { class _SpinnerButtonState extends State with TickerProviderStateMixin { late AnimationController _controller; + late SpinnerButtonController spinnerButtonController; @override void initState() { @@ -71,6 +97,7 @@ class _SpinnerButtonState extends State duration: widget.animationDuration, vsync: this, ); + spinnerButtonController=SpinnerButtonController(_controller); } @override @@ -91,7 +118,11 @@ class _SpinnerButtonState extends State progressIndicatorColor: widget.progressIndicatorColor, progressIndicatorSize: widget.progressIndicatorSize, borderRadius: widget.borderRadius, - onPressed: widget.onPressed, + onPressed: (controller){ + if(!spinnerButtonController.isInProgress){ + widget.onPressed(spinnerButtonController); + } + }, elevation: widget.elevation, child: widget.child, ), From e8c9e9ecf514646f423378d750e098a10bfb02a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tama=CC=81s=20Szabo=CC=81?= Date: Sat, 1 May 2021 02:42:13 +0200 Subject: [PATCH 4/6] Reverse animation fix --- lib/spinner_button.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/spinner_button.dart b/lib/spinner_button.dart index 9d4cd14..d83f057 100644 --- a/lib/spinner_button.dart +++ b/lib/spinner_button.dart @@ -22,7 +22,7 @@ class SpinnerButtonController{ if(isInProgress){ animationController.forward(); }else{ - animationController.reverse(); + animationController.reverse(from: animationController.value); } } From 5618eba8b6830b6afdb50e02808391fd8527d161 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tama=CC=81s=20Szabo=CC=81?= Date: Sun, 2 May 2021 23:55:22 +0200 Subject: [PATCH 5/6] Dispose check --- lib/spinner_button.dart | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/spinner_button.dart b/lib/spinner_button.dart index d83f057..a8c50d9 100644 --- a/lib/spinner_button.dart +++ b/lib/spinner_button.dart @@ -11,6 +11,7 @@ class SpinnerButtonController{ SpinnerButtonController(this.animationController); bool _isInProgress=false; + bool isDisposed=false; bool get isInProgress{ return _isInProgress; @@ -19,6 +20,10 @@ class SpinnerButtonController{ void set isInProgress(bool isInProgress) { _isInProgress=isInProgress; + if(isDisposed){ + return; + } + if(isInProgress){ animationController.forward(); }else{ @@ -27,6 +32,11 @@ class SpinnerButtonController{ } + void dispose(){ + isDisposed=true; + animationController.dispose(); + } + } class SpinnerButton extends StatefulWidget { @@ -102,7 +112,7 @@ class _SpinnerButtonState extends State @override void dispose() { - _controller.dispose(); + spinnerButtonController.dispose(); super.dispose(); } From 2ca6baa28cfd20656b16216a4aaf01fcc4e432ed Mon Sep 17 00:00:00 2001 From: Tamas Szabo Date: Tue, 15 Feb 2022 01:45:27 +0100 Subject: [PATCH 6/6] Padding fix --- lib/button_stagger_animation.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/button_stagger_animation.dart b/lib/button_stagger_animation.dart index aaa1679..802d391 100644 --- a/lib/button_stagger_animation.dart +++ b/lib/button_stagger_animation.dart @@ -84,6 +84,8 @@ class ButtonStaggerAnimation extends StatelessWidget { width: widthAnimation.value, child: ElevatedButton( style: ButtonStyle( + padding: MaterialStateProperty.all(EdgeInsets.zero), + minimumSize: MaterialStateProperty.all(Size(30, 30)), elevation: MaterialStateProperty.all(elevation), shape: MaterialStateProperty.all(RoundedRectangleBorder( borderRadius: borderRadiusAnimation.value,