So I made a timer and was wondering how can I add a "glow" that animates/grows slightly bigger , then back to a smaller glow. Another issue is that when I start the timer it updates every second (Sort of jumps instead of flowing)
Not sure how to go ahead with this as tried to google for a few hours now without luck.
Thank you for helping!
Here is my code
var maxSeconds = 900;
late int seconds = maxSeconds;
Timer? timer;
void resetTimer() {
setState(() => seconds = maxSeconds);
timer = null;
}
void startTimer({bool reset = true}) {
if (reset) {
resetTimer();
}
timer = Timer.periodic(Duration(seconds: 1), (_) {
if (!mounted) // Putting this line of code with return under, fixed my issue i been having about mounted
return;
else if (seconds > 0) {
setState(() => seconds--);
} else {
stopTimer(reset: false);
}
});
}
Widget buildTimer() => SizedBox(
width: 200,
height: 200,
child: Stack(
fit: StackFit.expand,
children: [
CircularProgressIndicator(
value: seconds / maxSeconds,
valueColor: AlwaysStoppedAnimation(Colors.white),
strokeWidth: 12,
backgroundColor: Colors.greenAccent,
),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
if (timer == null) {
HapticFeedback.heavyImpact();
} else {
}
},
child: Center(child: buildTime()),
),
],
),
);