AnimatedBuilder example

This Article is posted by seven.srikanth at 8/23/2020 8:36:54 AM

Here is an example of AnimatedBuilder in flutter. _MyAnimatedContainerState(contoller); } class _MyAnimatedContainerState extends State { int counter = 0; final AnimationController _controller; _MyAnimatedContainerState(this._controller); @override Widget build(BuildContext context) { return Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Padding( padding: const EdgeInsets.all(48.0), child: AnimatedBuilder( animation: _controller, builder: (BuildContext context, Widget child) { return Transform.rotate( angle: _controller.value * 2.0 * math.pi, child: Container( child: Text( 'Clicked $counter times', ), ), ); }, ), ), RaisedButton( onPressed: () { setState(() { counter++; }); }, child: Text('Click here '), ), ], ); } } class MyAnimatedContoller extends StatefulWidget { @override _MyAnimatedContollerState createState() => _MyAnimatedContollerState(); } class _MyAnimatedContollerState extends State with SingleTickerProviderStateMixin { AnimationController _controller; @override void initState() { super.initState(); _controller = AnimationController(duration: Duration(seconds: 1), vsync: this) ..repeat(); } @override void dispose() { super.dispose(); _controller.dispose(); } @override Widget build(BuildContext context) { return MyAnimatedContainer(contoller: _controller); } } ` Thanks,Srikanth

Tags:



0 Comments
Login to comment.
Recent Comments

Be the first to Comment. You can ask a Query or Share your toughts or Just say thanks.




© 2018 - Fluttercentral | Email to me - Seven.srikanth@gmail.com