removeNullOrEmpty method

void removeNullOrEmpty()

移除null值或空值

Implementation

void removeNullOrEmpty() {
  if (this == null || this!.isEmpty) return;
  var keys = List.from(this!.keys);
  for (Object key in keys) {
    Object? obj = this![key];
    if (obj == null) this?.remove(key);
    if (obj is String && obj.trim().isEmpty) {
      this?.remove(key);
    }
  }
  keys.clear();
}