compactMap<R extends Object> method
Filters nulls after applying transform.
Unlike the original, R is the actual return type of the transform,
so mapping to a different type is safe.
[1, 2, null, 3].compactMap((e) => e?.isEven == true ? 'even' : null);
// ('even')
Implementation
Iterable<R> compactMap<R extends Object>(R? Function(T?) transform) =>
map(transform).whereType<R>();