AnimatedBuilder should have a child
Providing a pre-built child is more efficient because we don't need to rebuild the child every tick of the animation.
This commit is contained in:
@@ -15,7 +15,7 @@ class PageSelectorDemo extends StatelessComponent {
|
||||
CurvedAnimation animation = new CurvedAnimation(parent: selection.animation, curve: Curves.ease);
|
||||
return new AnimatedBuilder(
|
||||
animation: animation,
|
||||
builder: (BuildContext context) {
|
||||
builder: (BuildContext context, Widget child) {
|
||||
Color background = selection.value == iconName ? _selectedColor.end : _selectedColor.begin;
|
||||
if (selection.valueIsChanging) {
|
||||
// Then the selection's performance is animating from previousValue to value.
|
||||
|
||||
@@ -47,7 +47,7 @@ class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> {
|
||||
controller.play(direction);
|
||||
}
|
||||
|
||||
Widget buildIndicators(BuildContext context) {
|
||||
Widget buildIndicators(BuildContext context, Widget child) {
|
||||
List<Widget> indicators = <Widget>[
|
||||
new SizedBox(
|
||||
width: 200.0,
|
||||
|
||||
@@ -41,7 +41,7 @@ class CardTransition extends StatelessComponent {
|
||||
Widget build(BuildContext context) {
|
||||
return new AnimatedBuilder(
|
||||
animation: animation,
|
||||
builder: (BuildContext context) {
|
||||
builder: (BuildContext context, Widget child) {
|
||||
double currentScale = scale.evaluate(animation);
|
||||
Matrix4 transform = new Matrix4.identity()
|
||||
..translate(x.evaluate(animation))
|
||||
@@ -53,7 +53,8 @@ class CardTransition extends StatelessComponent {
|
||||
child: child
|
||||
)
|
||||
);
|
||||
}
|
||||
},
|
||||
child: child
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user