buildPage method
- BuildContext context,
- Animation<
double> animation, - Animation<
double> secondaryAnimation
Override this method to build the primary content of this route.
The arguments have the following meanings:
context
: The context in which the route is being built.animation
: The animation for this route's transition. When entering, the animation runs forward from 0.0 to 1.0. When exiting, this animation runs backwards from 1.0 to 0.0.secondaryAnimation
: The animation for the route being pushed on top of this route. This animation lets this route coordinate with the entrance and exit transition of routes pushed on top of this route.
This method is only called when the route is first built, and rarely thereafter. In particular, it is not automatically called again when the route's state changes unless it uses ModalRoute.of. For a builder that is called every time the route's state changes, consider buildTransitions. For widgets that change their behavior when the route's state changes, consider ModalRoute.of to obtain a reference to the route; this will cause the widget to be rebuilt each time the route changes state.
In general, buildPage should be used to build the page contents, and buildTransitions for the widgets that change as the page is brought in and out of view. Avoid using buildTransitions for content that never changes; building such content once from buildPage is more efficient.
Implementation
@override
Widget buildPage(
BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
) {
final Widget child = builder(context);
final Widget result = Semantics(
scopesRoute: true,
explicitChildNodes: true,
child: child,
);
return result;
}