defaultRoutePageBuilder function

Page defaultRoutePageBuilder(
  1. BuildContext context,
  2. GoRouterState state, {
  3. Widget transitionsBuilder(
    1. BuildContext context,
    2. Animation<double> animation,
    3. Animation<double> secondaryAnimation,
    4. Widget child,
    )?,
  4. Duration? transitionDuration,
})

The default page builder for CMS routes.

Implementation

Page<dynamic> defaultRoutePageBuilder(
  BuildContext context,
  GoRouterState state, {
  Widget Function(BuildContext context, Animation<double> animation,
          Animation<double> secondaryAnimation, Widget child)?
      transitionsBuilder,
  Duration? transitionDuration,
}) {
  final route = state.extra as RouteBase?;

  if (route != null) {
    return route.createPage(context, state.pageKey);
  }

  final path = state.topRoute is CMSRoute
      ? (state.topRoute as CMSRoute).cmsPathResolver(state.matchedLocation)
      : state.matchedLocation;

  if (transitionsBuilder == null) {
    return MaterialPage(
      child: vyuh.content.buildRoute(context, url: Uri.parse(path)),
      name: state.matchedLocation,
      key: state.pageKey,
    );
  }

  return CustomTransitionPage<dynamic>(
    key: state.pageKey,
    child: vyuh.content.buildRoute(context, url: Uri.parse(path)),
    transitionsBuilder: transitionsBuilder,
    transitionDuration: transitionDuration ??
        const Duration(milliseconds: 300), // Increase the duration here
  );
}