Complete the code to create an AnimatedBuilder that listens to the animation.
AnimatedBuilder( animation: [1], builder: (context, child) { return Container(); }, )
The animation property must be set to the animation object, usually an AnimationController.
Complete the builder function to return a Transform widget that rotates based on the animation value.
AnimatedBuilder(
animation: animationController,
builder: (context, child) {
return Transform.rotate(
angle: [1],
child: child,
);
},
child: Icon(Icons.refresh),
)The angle property needs a double value from the animation, which is accessed by animationController.value.
Fix the error in the AnimatedBuilder code by completing the missing property to optimize rebuilds.
AnimatedBuilder( animation: animationController, builder: (context, [1]) { return Transform.scale( scale: animationController.value, child: [2], ); }, child: Container(color: Colors.blue, width: 100, height: 100), )
The builder function receives context and child. Using the child parameter avoids rebuilding the child widget unnecessarily.
Fill both blanks to create an AnimatedBuilder that changes opacity based on the animation value.
AnimatedBuilder( animation: [1], builder: (context, child) { return Opacity( opacity: [2], child: child, ); }, child: Text('Fade'), )
The animation property should be the animation controller, and the opacity uses the controller's current value.
Fill all three blanks to build an AnimatedBuilder that moves a widget horizontally using a translation transform.
AnimatedBuilder( animation: [1], builder: (context, child) { return Transform.translate( offset: Offset([2], 0), child: [3], ); }, child: Icon(Icons.directions_run), )
The animation property is the controller, the horizontal offset is the controller's value multiplied by 100 for visible movement, and the child widget is passed to avoid rebuilding.