whereBetween method

List<T> whereBetween(
  1. String key,
  2. num start,
  3. num end
)

Filters the collection by determining if a specified item value is within a given range

Example:

list.whereBetween("key",start, end)

Implementation

List<T> whereBetween(String key, num start, num end) {
  if (isEmpty) {
    return <T>[];
  }
  final List<T> result = <T>[];
  for (final T element in this) {
    if (element is Map<String, T> &&
        element.containsKey(key) &&
        element[key] is num) {
      if ((element[key] as int >= start) && (element[key] as int <= end)) {
        result.add(element);
      }
    }
  }

  return this;
}