deepCatchesValues<T> function

List deepCatchesValues<T>(
  1. Object? o,
  2. ValueFilter filter, [
  3. List? result
])

Catches deeply values that matches filter.

Returns a List of the matched values

Implementation

List deepCatchesValues<T>(Object? o, ValueFilter filter, [List? result]) {
  result ??= [];

  if (o == null) return result;

  if (filter(null, null, o)) {
    result.add(o);
  } else if (o is List) {
    deepCatchesListValues(o, filter, result);
  } else if (o is Map) {
    deepCatchesMapValues(o, filter, result);
  } else if (o is Set) {
    deepCatchesSetValues(o, filter, result);
  }

  return result;
}