PageTransition<T> constructor

PageTransition<T>({
  1. Key? key,
  2. Widget? child,
  3. ChildBuilder? childBuilder,
  4. required PageTransitionType type,
  5. Widget? childCurrent,
  6. BuildContext? ctx,
  7. bool inheritTheme = false,
  8. Curve curve = Curves.linear,
  9. Alignment? alignment,
  10. Duration duration = const Duration(milliseconds: 200),
  11. Duration? reverseDuration = const Duration(milliseconds: 200),
  12. bool fullscreenDialog = false,
  13. bool opaque = false,
  14. bool isIos = false,
  15. PageTransitionsBuilder matchingBuilder = const CupertinoPageTransitionsBuilder(),
  16. bool? maintainStateData,
  17. PageTransitionType? reverseType,
  18. RouteSettings? settings,
})

Page transition constructor. We can pass the next page either as a child widget or as a builder function.

Example using child:

PageTransition(
  type: PageTransitionType.rightToLeft,
  child: DetailPage(),
)

Example using builder:

PageTransition(
  type: PageTransitionType.rightToLeft,
  builder: (context) => DetailPage(),
)

Implementation

PageTransition({
  Key? key,
  this.child,
  this.childBuilder,
  required this.type,
  this.childCurrent,
  this.ctx,
  this.inheritTheme = false,
  this.curve = Curves.linear,
  this.alignment,
  this.duration = const Duration(milliseconds: 200),
  this.reverseDuration = const Duration(milliseconds: 200),
  this.fullscreenDialog = false,
  this.opaque = false,
  this.isIos = false,
  this.matchingBuilder = const CupertinoPageTransitionsBuilder(),
  this.maintainStateData,
  this.reverseType,
  RouteSettings? settings,
})  : assert(child != null || childBuilder != null,
          'Either child or childBuilder must be provided'),
      assert(!(child != null && childBuilder != null),
          'Cannot provide both child and childBuilder'),
      assert(inheritTheme ? ctx != null : true,
          "'ctx' cannot be null when 'inheritTheme' is true, set ctx: context"),
      super(
        pageBuilder: (context, animation, secondaryAnimation) {
          return childBuilder?.call(context) ?? child!;
        },
        settings: settings,
        maintainState: maintainStateData ?? true,
        opaque: opaque,
        fullscreenDialog: fullscreenDialog,
      );