deselect method

void deselect(
  1. Value valueToDeselect
)

Remove valueToDeselect from the value of the current state.

This method removes duplicate values.

Implementation

void deselect(Value valueToDeselect) {
  var newValue = state.value;
  newValue = [...newValue]..remove(valueToDeselect);
  if (_canUpdateValue(value: newValue, isInitialValue: false)) {
    final error = _getError(value: newValue);

    final isValidating =
        _getAsyncValidatorsError(value: newValue, error: error);

    emit(state.copyWith(
      isValueChanged: true,
      value: Param(newValue),
      error: Param(error),
      isValidated: _isValidated(isValidating),
      isValidating: isValidating,
    ));
  }
}