materialRoute static method

PageRoute materialRoute({
  1. String? routeName,
  2. Map? params,
  3. bool pushAnimated = true,
  4. bool popAnimated = true,
  5. bool maintainState = true,
  6. bool fullscreenDialog = false,
  7. WidgetBuilder? builder,
})

创建PageRoute pushAnimated 是否有进场动画 popAnimated 是否有退场动画

Implementation

static PageRoute materialRoute(
    {String? routeName,
    Map? params,
    bool pushAnimated = true,
    bool popAnimated = true,
    bool maintainState = true,
    bool fullscreenDialog = false,
    WidgetBuilder? builder}) {
  RouteSettings userSettings =
      RouteSettings(name: routeName, arguments: params);

  if (builder == null) {
    DStackWidgetBuilder stackWidgetBuilder =
        DStack.instance.pageBuilder(routeName);
    builder = stackWidgetBuilder(params);
  }

  DStackPageRouteBuilder route = DStackPageRouteBuilder(
    pageBuilder: builder,
    settings: userSettings,
    maintainState: maintainState,
    fullscreenDialog: fullscreenDialog,
    pushTransition: pushAnimated ? defaultPushDuration : Duration.zero,
    popTransition: popAnimated ? defaultPopDuration : Duration.zero,
  );
  return route;
}