decodePathWhen<T> function

T? decodePathWhen<T>(
  1. String path,
  2. Map<String, MatchCallback<T>> templateMap
)

Convenience function for decoding values from a given path that may match multiple possible templates.

Implementation

T? decodePathWhen<T>(String path, Map<String, MatchCallback<T>> templateMap) {
  for (final entry in templateMap.entries) {
    final pathMap = tryDecodePathMap(path: path, template: entry.key);
    if (pathMap != null) {
      return entry.value(pathMap, Uri.parse(path).queryParameters);
    }
  }

  return null;
}