createRoute method

  1. @override
Route createRoute(
  1. BuildContext context
)
override

Creates the Route that corresponds to this page.

The created Route must have its Route.settings property set to this Page.

Implementation

@override
Route createRoute(BuildContext context) {
  final settings =
      RouteSettings(name: path == '/' ? rootTarget : path, arguments: this);

  final routes =
      DartBoardCore.instance.routes.where((e) => e.matches(settings));

  if (routes.isNotEmpty) {
    final routeDef = routes.first;
    if (routeDef.routeBuilder != null) {
      return routeDef.routeBuilder!(
        settings,
        (builder != null)
            ? builder!
            : (context) => RouteWidget(path == '/' ? rootTarget : path),
      );
    }
  }

  if (!showAnimation) {
    return PageRouteBuilder(
        settings: this,
        pageBuilder: (context, animation1, animation2) => RouteWidget(
              path == '/' ? rootTarget : path,
              decorate: true,
            ),
        transitionDuration: Duration.zero);
  }

  return MaterialPageRoute(
    settings: this,
    builder: (builder != null)
        ? builder!
        : (context) => RouteWidget(
              path == '/' ? rootTarget : path,
              decorate: true,
            ),
  );
}