# match method

Map<String, String>? match(

1. String path

)

Matches a path string against the URI template and extracts values for declared path variables.

If the path matches the template format, this returns a `Map<String, String>` where keys are variable names and values are matched path segments.

Returns `null` if the path does not conform to the template.

### Example:

    final template = UriTemplate('/blog/{year}/{slug}');
    final result = template.match('/blog/2025/my-first-post');
    print(result); // {year: 2025, slug: my-first-post}

## Implementation

    Map<String, String>? match(String path) {
      final match = _pathRegex.firstMatch(path);
      if (match == null) {
        return null;
      }
      final result = <String, String>{};
      for (int i = 0; i < _variableNames.length; i++) {
        final value = match.group(i + 1); // Group 0 is the full match
        if (value != null) {
          result[_variableNames[i]] = value;
        } else {
          // This should not happen if the regex is built correctly for all variables
          return null;
        }
      }
      return result;
    }