getWorkBenchData function

dynamic getWorkBenchData(
  1. Map _workBench,
  2. dynamic key,
  3. dynamic value,
  4. dynamic otherInputText,
  5. dynamic _answeredCount,
  6. dynamic otherInput,
  7. dynamic isPhoneInput,
  8. dynamic phoneValue,
)

Implementation

getWorkBenchData(
  Map<dynamic, dynamic> _workBench,
  key,
  value,
  otherInputText,
  _answeredCount,
  otherInput,
  isPhoneInput,
  phoneValue,
) {
  if (value == null) {
    if (_workBench[key] != null && _workBench['${key}_phone'] != null) {
      _workBench.remove(key);
      _workBench.remove('${key}_phone');
    }

    if (_workBench[key] != null && _workBench['${key}_other'] != null) {
      _workBench.remove(key);
      _workBench.remove('${key}_other');
    }
    if (_workBench[key] != null) {
      _workBench.remove(key);
    }
  }

  if (value != null) {
    _answeredCount += 1;
    if (otherInput == true) {
      var _newMap = {..._workBench};
      _newMap[key] = value;
      _newMap['${key}_other'] = otherInputText;
      _workBench = _newMap;
    } else if (isPhoneInput) {
      var _newMap = {..._workBench};
      _newMap[key] = value;
      _newMap['${key}_phone'] = phoneValue;
      _workBench = _newMap;
    } else {
      _workBench[key] = value;
    }
  }

  return _workBench;
}