setValueByKey method

void setValueByKey(
  1. dynamic chiTietDon,
  2. String key, {
  3. dynamic value = "",
})

Implementation

void setValueByKey(dynamic chiTietDon, String key, {dynamic value = ""}) {
  Control control = findControlInputFormAllPage(key);

  if (value != "" && value != null) {
    control.value.value = value;
    return;
  }

  if (control.formatShow == FormatValuePresent.Percent) {
    control.value.value = chiTietDon[key.toUpperCase()]?.toString() ?? "0";
  } else if (control.formatShow == FormatValuePresent.Money) {
    control.value.value =
        chiTietDon[key.toUpperCase()]?.toInt()?.toString() ?? "0";
  } else {
    if (chiTietDon[key.toUpperCase()] != null) {
      control.value.value = chiTietDon[key.toUpperCase()]?.toString() ?? "";
    } else {
      control.value.value = "";
    }
  }
}