removeKeys method

bool removeKeys(
  1. List<String>? removeKeysList, {
  2. bool recurseChildValues = true,
})

Removes specified keys from this map.

Args: removeKeysList: List of keys to remove. recurseChildValues: If true, also removes keys from nested maps.

Returns: True if any modifications were made.

Implementation

bool removeKeys(List<String>? removeKeysList, {bool recurseChildValues = true}) {
  if (removeKeysList == null || removeKeysList.isEmpty) return false;
  removeWhere((String key, _) => removeKeysList.contains(key));
  if (recurseChildValues) {
    // ignore: require_future_error_handling
    updateAll((String _, dynamic value) {
      if (value is Map<String, dynamic>) value.removeKeys(removeKeysList);
      return value;
    });
  }
  return true;
}