pluck method

List<T?> pluck(
  1. String key
)

Retrieves all values for a given key from a list of maps.

key is the key to pluck values for.

Example:

final ids = list.pluck("id");

Implementation

List<T?> pluck(String key) {
  if (isEmpty) {
    return <T>[];
  }
  return whereType<Map<String, T>>()
      .where((map) => map.containsKey(key))
      .map((map) => map[key])
      .toList();
}