compact method

List<T> compact()

Removes null and empty (String/Iterable/Map) elements.

Implementation

List<T> compact() => where((e) {
      if (e == null) return false;
      if (e is String) return e.isNotEmpty;
      if (e is Iterable) return e.isNotEmpty;
      if (e is Map) return e.isNotEmpty;
      return true;
    }).toList();