A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://pub.dev/documentation/github/latest/github/../github/createNonNullMap.html below:

createNonNullMap function - github library

createNonNullMap<K, V> function

Map<K, V?> createNonNullMap

<

K

,

V

>(

  1. Map<K, V> input, {
  2. bool recursive = true,

})

Returns a new map containing only the entries of input whose value is not null.

If recursive is true, nested maps are also filtered.

Implementation
Map<K, V?> createNonNullMap<K, V>(Map<K, V> input, {bool recursive = true}) {
  final map = <K, V?>{};
  for (final entry in input.entries) {
    if (entry.value != null) {
      map[entry.key] = recursive && entry.value is Map
          ? createNonNullMap(entry.value as Map, recursive: recursive) as V?
          : entry.value;
    }
  }
  return map;
}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4