general_lib_utils_removeRecursiveByKeys method

void general_lib_utils_removeRecursiveByKeys({
  1. required List<String> keyDatas,
})

Implementation

void general_lib_utils_removeRecursiveByKeys({
  required List<String> keyDatas,
}) {
  removeWhere((key, value) {
    if (keyDatas.contains(key)) {
      return true;
    }

    if (value is Map) {
      value.general_lib_utils_removeRecursiveByKeys(keyDatas: keyDatas);
    } else if (value is JsonScheme) {
      value.rawData
          .general_lib_utils_removeRecursiveByKeys(keyDatas: keyDatas);
    }

    if (value is List<Map>) {
      for (var element in value) {
        element.general_lib_utils_removeRecursiveByKeys(keyDatas: keyDatas);
      }
    } else if (value is List<JsonScheme>) {
      for (var element in value) {
        element.rawData
            .general_lib_utils_removeRecursiveByKeys(keyDatas: keyDatas);
      }
    }

    return false;
  });
}