Created
April 24, 2021 12:13
-
-
Save AbhishekDoshi26/699d1c3f8554f630b1883b1751a73ac9 to your computer and use it in GitHub Desktop.
Lottie Animation Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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