From 4d68dcf2f78e3cac1836f1a0ee5bcff755c4a50f Mon Sep 17 00:00:00 2001 From: AmirrezaChegini Date: Wed, 24 Dec 2025 00:13:51 +0330 Subject: [PATCH] fix: globe animation --- .../widgets/animations/globe_animation.dart | 64 ++++++------------- .../ui/screens/question_screen.dart | 1 - 2 files changed, 21 insertions(+), 44 deletions(-) diff --git a/lib/core/widgets/animations/globe_animation.dart b/lib/core/widgets/animations/globe_animation.dart index d37f6d8..6585db9 100644 --- a/lib/core/widgets/animations/globe_animation.dart +++ b/lib/core/widgets/animations/globe_animation.dart @@ -4,10 +4,9 @@ import 'package:flutter/material.dart'; import 'package:hadi_hoda_flutter/common_ui/resources/my_spaces.dart'; class GlobeAnimation extends StatefulWidget { - const GlobeAnimation({super.key, required this.child, this.state = true}); + const GlobeAnimation({super.key, required this.child}); final Widget child; - final bool state; @override State createState() => _GlobeAnimationState(); @@ -32,48 +31,27 @@ class _GlobeAnimationState extends State begin: 1, end: 1.05, ).animate(CurvedAnimation(parent: _controller, curve: Curves.linear)); - } - @override - void didUpdateWidget(covariant GlobeAnimation oldWidget) { - super.didUpdateWidget(oldWidget); - if (widget.state) { - _controller.repeat(reverse: true); - _timer = Timer.periodic(const Duration(seconds: 1), (timer) { - if (_gradient == null) { - if (!mounted) return; - setState(() { - _gradient = RadialGradient( - colors: [ - const Color(0XFFDFCD00), - const Color(0XFFDFCD00).withValues(alpha: 0.35), - const Color(0XFFDFCD00).withValues(alpha: 0), - ], - center: Alignment.center, - ); - }); - } else { - setState(() { - _gradient = null; - }); - } - }); - } else { - _timer?.cancel(); - _timer = null; - _controller.stop(); - if (!mounted) return; - setState(() { - _gradient = RadialGradient( - colors: [ - const Color(0XFFDFCD00).withValues(alpha: 0), - const Color(0XFFDFCD00).withValues(alpha: 0), - const Color(0XFFDFCD00).withValues(alpha: 0), - ], - center: Alignment.center, - ); - }); - } + _controller.repeat(reverse: true); + _timer = Timer.periodic(const Duration(seconds: 1), (timer) { + if (_gradient == null) { + if (!mounted) return; + setState(() { + _gradient = RadialGradient( + colors: [ + const Color(0XFFDFCD00), + const Color(0XFFDFCD00).withValues(alpha: 0.35), + const Color(0XFFDFCD00).withValues(alpha: 0), + ], + center: Alignment.center, + ); + }); + } else { + setState(() { + _gradient = null; + }); + } + }); } @override diff --git a/lib/features/question/presentation/ui/screens/question_screen.dart b/lib/features/question/presentation/ui/screens/question_screen.dart index b15a7d3..9fc09aa 100644 --- a/lib/features/question/presentation/ui/screens/question_screen.dart +++ b/lib/features/question/presentation/ui/screens/question_screen.dart @@ -389,7 +389,6 @@ class _QuestionScreenState extends State alignment: AlignmentDirectional.centerStart, children: [ GlobeAnimation( - state: true, child: MyImage( image: MyAssets.globe, fit: BoxFit.cover,