getRouteBuilderForPath method

_RoutePathWithBuilder getRouteBuilderForPath(
  1. String path
)

Implementation

_RoutePathWithBuilder getRouteBuilderForPath(String path) {
  _RoutePathWithBuilder? matchingRoute;

  widget.routes.forEach((key, value) {
    if (checkPathMatchesRoute(path, key) && matchingRoute == null) {
      matchingRoute = _RoutePathWithBuilder(key.join(','), value);
    }
  });

  if (matchingRoute == null) {
    debugPrint('WARNING: Unable to find a route for $path');
    matchingRoute = _RoutePathWithBuilder(
      '404',
      FlyRouteBuilder(
        builder: (c, _) {
          return widget.unknownPathBuilder?.call(c) ??
              Scaffold(
                body: Center(
                  child: Column(
                    mainAxisSize: MainAxisSize.min,
                    children: [
                      const Text(
                        'Page Not Found :(',
                        style: TextStyle(fontSize: 26),
                      ),
                      Text("Unable to match a route to: '$path'"),
                    ],
                  ),
                ),
              );
        },
      ),
    );
  } else {}
  return matchingRoute!;
}