extractHeaderMapValues function

Map<String, String>? extractHeaderMapValues(
  1. Map<String, String>? headers,
  2. String name
)

Implementation

Map<String, String>? extractHeaderMapValues(
    Map<String, String>? headers, String name) {
  if (headers == null) return null;
  return Map<String, String>.fromEntries(headers.entries
      .where((e) => e.key.toLowerCase().startsWith(name.toLowerCase()))
      .map((e) => MapEntry(e.key.substring(name.length), e.value)));
}