value method

String? value(
  1. String name
)

Convenience method for the value for a single valued header. If there is no header with the provided name, null will be returned. If the header has more than one value an exception is thrown.

Implementation

String? value(String name) {
  final arr = this[name];
  if (arr == null) {
    return null;
  }
  if (arr.length == 1) {
    return arr.first;
  }
  throw Exception(
    '"$name" header has more than one value, please use Headers[name]',
  );
}