getFirstValue method

String? getFirstValue(
  1. K key, {
  2. bool ignoreCase = false,
})

Returns the first value for key, if present.

Implementation

String? getFirstValue(K key, {bool ignoreCase = false}) {
  var prev = ignoreCase ? getIgnoreCase(key) : get(key);

  if (prev == null) return null;
  if (prev is String) return prev;

  if (prev is List<String>) return prev.isEmpty ? null : prev.first;

  if (prev is List) return prev.isEmpty ? null : prev.first.toString();

  return null;
}