parse method

Map<String, String>? parse(
  1. String line
)

Parses line into field → value, or null if the line doesn't match the template. Missing optional captures come back as empty strings. Audited: 2026-06-12 11:26 EDT

Implementation

Map<String, String>? parse(String line) {
  final RegExpMatch? match = _regex.firstMatch(line);
  if (match == null) {
    return null;
  }
  return <String, String>{
    for (final String field in _fields) field: match.namedGroup(field) ?? '',
  };
}