visitAll<T> function

List<T> visitAll<T>(
  1. Iterable<DartObject> objs,
  2. T? recurseFn(
    1. DartObject
    )
)

Visits all of the DartObjects, accumulating the results of recuseFn.

If the DartObject is a list, then it will recursively visitAll on that list. Otherwise, then it will call recuseFn on the object.

Implementation

List<T> visitAll<T>(
    Iterable<DartObject> objs, T? Function(DartObject) recurseFn) {
  var metadata = <T>[];
  for (var obj in objs) {
    var maybeList = obj.toListValue();
    if (maybeList != null) {
      metadata.addAll(visitAll<T>(maybeList, recurseFn));
    } else {
      var value = recurseFn(obj);
      if (value != null) {
        metadata.add(value);
      }
    }
  }
  return metadata;
}