builder property

  1. @override
RouteWidgetBuilder builder
override

This is the builder for the content

Implementation

@override
RouteWidgetBuilder get builder => (ctx, settings) {
      final url = Uri.tryParse(settings.name!);
      if (url == null) return Text('not found');
      RouteDefinition? lastMatching;

      for (var i = 0; i < url.pathSegments.length; i++) {
        var hasMatchAtLevel = false;
        final part = url.pathSegments[i];
        for (final matcher in routes[i]) {
          if (matcher.matches(RouteSettings(name: '/$part'))) {
            lastMatching = matcher;
            hasMatchAtLevel = true;
          }
        }
        if (!hasMatchAtLevel) return Text('No match at level');
      }
      return lastMatching?.builder(ctx, settings) ?? Text('No match found');
    };