How do I play lottie animation by a button click.What I want is the lottie animation should play until I press the button to stop it
Here is my code:
class _DashboardState extends State<Dashboard> with TickerProviderStateMixin{
late AnimationController _animationController;
@override
void initState() {
super.initState();
_animationController =
AnimationController(vsync: this, duration: const Duration(milliseconds: 500));
}
// ...
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children:[
SizedBox(
height: 300,
child: Lottie.asset('assets/animation_soundwave.json',
controller: _animationController,
height: 180,
repeat: false,
),
),
GestureDetector(
onTap: () {
_animationController.forward();
},
child:IconButton()
),