oldestFirst method

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

The oldestFirst methods allow you to easily order results by id and get first record. By default, the result will be ordered by the id field. Or, you may pass the column name that you wish to sort by:

Example:

list.oldestFirst()

Implementation

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