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