pushWithAnimation static method

Future pushWithAnimation(
  1. String routeName,
  2. PageType pageType,
  3. PushAnimationPageBuilder animationBuilder, {
  4. Map? params,
  5. bool? replace,
  6. Duration? pushDuration,
  7. Duration? popDuration,
  8. bool popGesture = false,
})

自定义进场动画 animationBuilder 进场动画的builder pushDuration 进场时间 popDuration 退场时间

Implementation

static Future pushWithAnimation(
  String routeName,
  PageType pageType,
  PushAnimationPageBuilder animationBuilder, {
  Map? params,
  bool? replace,
  Duration? pushDuration,
  Duration? popDuration,
  bool popGesture = false,
}) {
  if (pageType == PageType.flutter) {
    RouteSettings settings =
        RouteSettings(name: routeName, arguments: params);
    DStackWidgetBuilder stackWidgetBuilder =
        DStack.instance.pageBuilder(routeName);
    WidgetBuilder builder = stackWidgetBuilder(params);
    PageRoute route = DStackPageRouteBuilder(
        pageBuilder: builder,
        settings: settings,
        pushTransition: pushDuration,
        popTransition: popDuration,
        animationBuilder: animationBuilder,
        popGesture: popGesture);
    if (replace!) {
      DNavigatorManager.nodeHandle(
          routeName, pageType, DStackConstant.replace,
          result: {}, route: route);
      return _navigator!.pushReplacement(route);
    }
    DNavigatorManager.nodeHandle(routeName, pageType, DStackConstant.push,
        result: {}, route: route);
    return _navigator!.push(route);
  } else {
    DNavigatorManager.nodeHandle(routeName, pageType, DStackConstant.push,
        result: params);
    return Future.value(true);
  }
}