<p>Here is an example of AnimatedBuilder in flutter.</p> <pre> _MyAnimatedContainerState(contoller); </pre> <p>}</p> <p>class _MyAnimatedContainerState extends State { int counter = 0; final AnimationController _controller;</p> <p>_MyAnimatedContainerState(this._controller);</p> <p>@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 '), ), ], ); } }</p> <p>class MyAnimatedContoller extends StatefulWidget { @override _MyAnimatedContollerState createState() => _MyAnimatedContollerState(); }</p> <p>class _MyAnimatedContollerState extends State with SingleTickerProviderStateMixin { AnimationController _controller;</p> <p>@override void initState() { super.initState(); _controller = AnimationController(duration: Duration(seconds: 1), vsync: this) ..repeat(); }</p> <p>@override void dispose() { super.dispose(); _controller.dispose(); }</p> <p>@override Widget build(BuildContext context) { return MyAnimatedContainer(contoller: _controller); } } ` Thanks,Srikanth</p>
AnimatedBuilder example
This Article is posted by seven.srikanth at 8/23/2020 8:36:54 AM
Check out our other latest articles
Safearea widget - How to avoid visual overlap with Notch on flutter mobile app?How to convert row of widgets into column of widgets in flutter based on screen size?
How to run Flutter programs from GitHub?
How to get screen orientation in flutter?
NavigationRail example in flutter
Tags:
Check out our other latest articles
Safearea widget - How to avoid visual overlap with Notch on flutter mobile app?How to convert row of widgets into column of widgets in flutter based on screen size?
How to run Flutter programs from GitHub?
How to get screen orientation in flutter?
NavigationRail example in flutter