Icon should be blink 3 times and then it should stop blinking. Icon should be visible after blink gets stopped
functioning properly and scheduler throwing exception after stopping
This exception was thrown in the context of a scheduler callback. When
the scheduler callback was registered (as opposed to when the
exception was thrown), this was the stack:
class MyBlinkingIcon extends StatefulWidget {
const MyBlinkingIcon({super.key});
@override
MyBlinkingIconState createState() => MyBlinkingIconState();
}
class MyBlinkingIconState extends State<MyBlinkingIcon>
with SingleTickerProviderStateMixin {
late AnimationController _animationController;
int _counter = 0;
@override
void initState() {
_animationController =
AnimationController(vsync: this, duration: const Duration(seconds: 1));
_animationController.repeat(reverse: true);
super.initState();
_animationController.addStatusListener((status) {
_counter++;
if (_counter == 4) {
_animationController.stop();
}
setState(() {});
});
}
@override
Widget build(BuildContext context) {
return _counter > 3 ?Assets.svgs.flame.svg() :FadeTransition(
opacity: _animationController,
child: Assets.svgs.flame.svg(),
) ;
}
@override
void dispose() {
_animationController.dispose();
super.dispose();
}
}