buildTransitions<T> method
- PageRoute<
T> route, - BuildContext context,
- Animation<
double> animation, - Animation<
double> secondaryAnimation, - Widget child,
override
Wraps the child with one or more transition widgets which define how route
arrives on and leaves the screen.
Subclasses override this method to create a transition animation.
The MaterialPageRoute.buildTransitions method is an example of a method
that uses this to build a transition. It looks up the current
PageTransitionsTheme with Theme.of(context).pageTransitionsTheme
and delegates to this method with a PageTransitionsBuilder based
on the theme's ThemeData.platform.
Implementation
@override
Widget buildTransitions<T>(
PageRoute<T> route,
BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child,
) {
return _PredictiveBackGestureDetector(
route: route,
builder:
(
BuildContext context,
_PredictiveBackPhase phase,
PredictiveBackEvent? startBackEvent,
PredictiveBackEvent? currentBackEvent,
) {
// Only do a predictive back transition when the user is performing a
// pop gesture. Otherwise, for things like button presses or other
// programmatic navigation, fall back to ZoomPageTransitionsBuilder.
if (route.popGestureInProgress) {
return _PredictiveBackFullscreenPageTransition(
animation: animation,
secondaryAnimation: secondaryAnimation,
getIsCurrent: () => route.isCurrent,
phase: phase,
child: child,
);
}
return const ZoomPageTransitionsBuilder().buildTransitions(
route,
context,
animation,
secondaryAnimation,
child,
);
},
);
}