oldestFirst method

Map<T, T> oldestFirst([
  1. String key = 'id'
])

Returns the first item from a list of maps sorted by the given key in ascending order.

By default, it sorts by the 'id' key.

Example:

final oldestItem = list.oldestFirst("timestamp");

Implementation

Map<T, T> oldestFirst([String key = 'id']) {
  final List<Map<T, T>> sortedMaps = oldest(key);
  return sortedMaps.isNotEmpty ? sortedMaps.first : <T, T>{};
}