firstEntry property

MapEntry<K, V>? get firstEntry

Returns the first key-value pair, or null if the map is empty.

Example:

{'a': 1, 'b': 2}.firstEntry; // MapEntry('a', 1)
{}.firstEntry; // null

Implementation

MapEntry<K, V>? get firstEntry {
  if (isEmpty) return null;
  return entries.first;
}