compactMap<E> method
Maps and filters out null values from the iterable.
If transform is provided, each element is first transformed and then filtered.
If not, the original values are used as-is.
Implementation
Iterable<T> compactMap<E>([E? Function(T?)? transform]) {
return map(transform ?? (e) => e).where((e) => e != null).cast();
}