hashNewData method

bool hashNewData(
  1. Map data
)

Implementation

bool hashNewData(Map data) {
  bool is_new_data = false;

  for (var element in data.entries) {
    // check dulu apakah ada kunci yang tidak sama jika tidak ada langsung break agar irit cpu
    if (containsKey(element.key) == false) {
      is_new_data = true;
      break;
    }
    // check new data
    dynamic value = element.value;

    if (value is Map) {
      if (this[element.key] is Map) {
        is_new_data = (this[element.key] as Map).hashNewData(value);
        if (is_new_data) {
          break;
        }
      } else {
        is_new_data = true;
        break;
      }
    } else if (value is List) {
      if (this[element.key] is List) {
        is_new_data = (this[element.key] as List).hashNewData(value);
        if (is_new_data) {
          break;
        }
      } else {
        is_new_data = true;
        break;
      }
    } else if (value != this[element.key]) {
      is_new_data = true;
      break;
    }
  }

  return is_new_data;
}