general_lib_utils_updateMapWithReplace method

void general_lib_utils_updateMapWithReplace({
  1. required Map data,
  2. required List<String> ignoreKeys,
})

Implementation

void general_lib_utils_updateMapWithReplace({
  required Map data,
  required List<String> ignoreKeys,
}) {
  data.general_lib_utils_removeRecursiveByKeys(keyDatas: ignoreKeys);
  data.forEach((key, value) {
    if (ignoreKeys.contains(key)) {
      return;
    }
    try {
      if (value == null) {
        return;
      }
      if (value is String) {
        if (value.isEmpty) {
          return;
        }
      }
      if (value is Map && this[key] is Map) {
        (this[key] as Map).general_lib_utils_updateMapWithReplace(
            data: value, ignoreKeys: ignoreKeys);
      } else if (value is List && this[key] is List) {
        if (value is List<Map> && this[key] is List<Map>) {}
      } else {
        this[key] = value;
      }
    } catch (e) {}
  });
  return;
}