getAnswerValueToStore function

dynamic getAnswerValueToStore(
  1. dynamic value,
  2. dynamic otherInput,
  3. dynamic otherInputText,
  4. dynamic otherInputId,
  5. dynamic isPhoneInput,
  6. dynamic phoneValue,
)

Implementation

getAnswerValueToStore(
    value, otherInput, otherInputText, otherInputId, isPhoneInput, phoneValue) {
  if (otherInput == false && isPhoneInput == false) {
    return value;
  }

  if (isPhoneInput == true) {
    return phoneValue;
  }

  if (otherInput == true) {
    var newValue = [...value];
    var otherInputIndex = newValue.indexOf(otherInputId);
    newValue[otherInputIndex] = {
      'id': otherInputId,
      'other_txt': otherInputText
    };
    return newValue;
  }
}