Skip to content

Instantly share code, notes, and snippets.

@AbhishekDoshi26
Created April 24, 2021 12:13
Show Gist options
  • Save AbhishekDoshi26/699d1c3f8554f630b1883b1751a73ac9 to your computer and use it in GitHub Desktop.
Save AbhishekDoshi26/699d1c3f8554f630b1883b1751a73ac9 to your computer and use it in GitHub Desktop.
Lottie Animation Example
class LottieAnimationExample extends StatefulWidget{
@override
LottieAnimationExampleState createState() => LottieAnimationExampleState();
}
class LottieAnimationExampleState extends State<LottieAnimationExample> with TickerProviderStateMixin{
AnimationController _lottieAnimationController;
@override
void initState(){
_lottieAnimationController = AnimationController(vsync: this);
}
@override
Widget build(BuildContext context){
return Scaffold(
body: GestureDetector(
onTap: () => _lottieAnimationController.forward();
child: Center(
child: Lottie.asset(
'assets/lottie.json',
controller: _lottieAnimationController,
height: 36.0,
onLoaded: (composition) {
_lottieAnimationController..duration = composition.duration;
}
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment