mapNotNull<T> method

List<T> mapNotNull<T>(
  1. T transform(
    1. String,
    2. dynamic
    )
)

Returns a list containing the results of applying the given transform function to each element in the original Map. If the tranform returns null, it is not included in the output list.

Implementation

List<T> mapNotNull<T>(T Function(String, dynamic) transform) {
  List<T> result = [];
  if (this != null) {
    for (String key in this!.keys) {
      T transformedValue = transform(key, this![key]);
      if (transformedValue != null) {
        result.add(transformedValue);
      }
    }
  }
  return result;
}