general_lib_utils_updateMapIfNotSameOrEmptyOrNull method

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

Implementation

void general_lib_utils_updateMapIfNotSameOrEmptyOrNull({
  required Map data,
  required List<String> ignoreKeys,
}) {
  data.general_lib_utils_removeRecursiveByKeys(keyDatas: ignoreKeys);
  data.forEach((key, value) {
    if (ignoreKeys.contains(key)) {
      return;
    }
    try {
      // jika tidak ada key
      if (!containsKey(key)) {
        this[key] = value;
        return;
      }

      // jika ada value
      if (this[key] == null) {
        this[key] = value;
      } else if (value is Map && this[key] is Map) {
        (this[key] as Map).general_lib_utils_updateMapIfNotSameOrEmptyOrNull(
            data: value, ignoreKeys: ignoreKeys);
      } else if (value is List && this[key] is List) {
        if (value is List<Map> && this[key] is List<Map>) {}
      }
    } catch (e) {}
  });
  return;
}