select method

void select(
  1. Value valueToSelect
)

Add valueToSelect to the value of the current state.

This method removes duplicate values.

Implementation

void select(Value valueToSelect) {
  var newValue = state.value;
  newValue =
      SingleFieldBloc._itemsWithoutDuplicates([...newValue, valueToSelect]);
  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,
    ));
  }
}