checkCondition method

dynamic checkCondition(
  1. int userRequestedValue,
  2. Function validator,
  3. TextEditingController controller,
  4. String key,
  5. dynamic oldValue,
)

Checks condition new value and passed validator, sets that in map and return new value;

Implementation

dynamic checkCondition(int userRequestedValue, Function validator,
    TextEditingController controller, String key, dynamic oldValue) {
  dynamic newValue;

  /// If the userRequested Value is grater than 0 that means user select them and we have to check new value;
  if (userRequestedValue > 0) {
    newValue = validator(controller.text, userRequestedValue);
  } else
    newValue = null;

  if (newValue == null)
    return null;
  else if (newValue != oldValue) {
    _selectedCondition![key] = newValue;
    return newValue;
  } else
    return oldValue;
}