Skip to content

An open-source cross-platform alternative to AirDrop

feat: update rotating widget

Tien Do Namf983b934e3f9
diff --git a/lib/widget/rotating_widget.dart b/lib/widget/rotating_widget.dart
index 1b77ec33..c0dfe1e4 100644
--- a/lib/widget/rotating_widget.dart
+++ b/lib/widget/rotating_widget.dart
@@ -4,9 +4,17 @@ class RotatingWidget extends StatefulWidget {
final Duration duration;
final bool spinning;
final bool reverse;
+ final bool pauseOnStop; // only pause the rotation animation (instead of reset)
final Widget child;
- const RotatingWidget({required this.duration, this.spinning = true, this.reverse = false, required this.child, super.key});
+ const RotatingWidget({
+ required this.duration,
+ this.spinning = true,
+ this.reverse = false,
+ this.pauseOnStop = false,
+ required this.child,
+ super.key,
+ });
@override
State<RotatingWidget> createState() => RotatingWidgetState();
@@ -46,7 +54,11 @@ class RotatingWidgetState extends State<RotatingWidget> with TickerProviderState
void didUpdateWidget(RotatingWidget oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.spinning && !widget.spinning) {
- _controller.stop();
+ if (widget.pauseOnStop) {
+ _controller.stop();
+ } else {
+ _controller.reset();
+ }
} else if (!oldWidget.spinning && widget.spinning) {
_controller.repeat();
}