CupertinoPageTransition constructor Null safety

CupertinoPageTransition(
  1. {Key? key,
  2. required Animation<double> primaryRouteAnimation,
  3. required Animation<double> secondaryRouteAnimation,
  4. required Widget child,
  5. required bool linearTransition}
)

Creates an iOS-style page transition.

  • primaryRouteAnimation is a linear route animation from 0.0 to 1.0 when this screen is being pushed.
  • secondaryRouteAnimation is a linear route animation from 0.0 to 1.0 when another screen is being pushed on top of this one.
  • linearTransition is whether to perform the transitions linearly. Used to precisely track back gesture drags.

Implementation

CupertinoPageTransition({
  super.key,
  required Animation<double> primaryRouteAnimation,
  required Animation<double> secondaryRouteAnimation,
  required this.child,
  required bool linearTransition,
}) : assert(linearTransition != null),
     _primaryPositionAnimation =
         (linearTransition
           ? primaryRouteAnimation
           : CurvedAnimation(
               // The curves below have been rigorously derived from plots of native
               // iOS animation frames. Specifically, a video was taken of a page
               // transition animation and the distance in each frame that the page
               // moved was measured. A best fit bezier curve was the fitted to the
               // point set, which is linearToEaseIn. Conversely, easeInToLinear is the
               // reflection over the origin of linearToEaseIn.
               parent: primaryRouteAnimation,
               curve: Curves.linearToEaseOut,
               reverseCurve: Curves.easeInToLinear,
             )
         ).drive(_kRightMiddleTween),
     _secondaryPositionAnimation =
         (linearTransition
           ? secondaryRouteAnimation
           : CurvedAnimation(
               parent: secondaryRouteAnimation,
               curve: Curves.linearToEaseOut,
               reverseCurve: Curves.easeInToLinear,
             )
         ).drive(_kMiddleLeftTween),
     _primaryShadowAnimation =
         (linearTransition
           ? primaryRouteAnimation
           : CurvedAnimation(
               parent: primaryRouteAnimation,
               curve: Curves.linearToEaseOut,
             )
         ).drive(_CupertinoEdgeShadowDecoration.kTween);