SingleFieldBloc<Value, Suggestion, State extends FieldBlocState<Value, Suggestion, ExtraData>, ExtraData> class abstract

The base class with the common behavior of all single field blocs:

Mixed-in types
Implementers

Constructors

SingleFieldBloc({Equality<Value> equality = const DefaultEquality<Never>(), required List<Validator<Value>>? validators, required List<AsyncValidator<Value>>? asyncValidators, required Duration asyncValidatorDebounceTime, required State initialState})

Properties

hashCode int
The hash code for this object.
no setterinherited
hasInitialValue bool
Indicate if this field has value from FieldBloc.updateInitialValue method. FieldBlocState.hasInitialValue
no setter
hasUpdatedValue bool
Indicate if this field has value from FieldBloc.updateValue method. FieldBlocState.hasUpdatedValue
no setter
isClosed bool
Whether the bloc is closed.
no setterinherited
isValueChanged bool
Returns true when the value has been changed by FieldBloc.changeValue. FieldBlocState.isValueChanged
no setter
name String
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selectedSuggestion Stream<Suggestion>
Returns Stream of selected Suggestions.
no setter
state → State
The current state.
no setterinherited
stream Stream<State>
The current stream of states.
no setterinherited
value → Value
Returns the value of the current state.
no setter

Methods

addAsyncValidators(List<AsyncValidator<Value>> asyncValidators, {bool forceValidation = false}) → void
Add asyncValidators to the current validators for check if value of the current state has an error.
addError(Object error, [StackTrace? stackTrace]) → void
Reports an error which triggers onError with an optional StackTrace.
inherited
addFieldError(Object error, {bool isPermanent = false}) → void
If isPermanent is false, add an error to FieldBlocState.error.
addValidators(List<Validator<Value>> validators, {bool forceValidation = false}) → void
Add validators to the current validators for check if value of the current state has an error.
changeValue(Value value) → void
clear() → void
Set the value to initialValue of the current state.
close() Future<void>
Closes the instance. This method should be called when the instance is no longer needed. Once close is called, the instance can no longer be used.
emit(State state) → void
Updates the state to the provided state. emit does nothing if the state being emitted is equal to the current state.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onChange(Change<State> change) → void
Called whenever a change occurs with the given change. A change occurs when a new state is emitted. onChange is called before the state of the cubit is updated. onChange is a great spot to add logging/analytics for a specific cubit.
inherited
onError(Object error, StackTrace stackTrace) → void
Called whenever an error occurs and notifies BlocObserver.onError.
inherited
onValueChanges<R>({Duration debounceTime = const Duration(), void onStart(State previous, State current)?, required Stream<R> onData(State previous, State current), void onFinish(State previous, State current, R result)?}) StreamSubscription
Returns a StreamSubscription<R>,
removeAsyncValidators(List<AsyncValidator<Value>> asyncValidators, {bool forceValidation = false}) → void
Add asyncValidators to the current validators for check if value of the current state has an error.
removeFormBloc(FormBloc formBloc) → void
Remove the formBloc to the fieldBloc See FieldBloc.removeFormBloc
override
removeValidators(List<Validator<Value>> validators, {bool forceValidation = false}) → void
Add validators to the current validators for check if value of the current state has an error.
resetStateIsValidated() → void
selectSuggestion(Suggestion suggestion) → void
Add a suggestion to selectedSuggestion.
subscribeToFieldBlocs(List<FieldBloc<FieldBlocStateBase>> fieldBlocs) → void
Create a subscription to the state of each fieldBloc in FieldBlocs, When any state changes, this fieldBloc will be revalidated. This is useful when you have validators that uses the state of other fieldBloc, for example when you want the correct behavior of validator that confirms a password with the password of other fieldBloc.
toString() String
A string representation of this object.
override
updateAsyncValidators(List<AsyncValidator<Value>> asyncValidators, {bool forceValidation = false}) → void
Updates the current asyncValidators with asyncValidators.
updateExtraData(ExtraData extraData) → void
{@template form_bloc.FieldBloc.updateExtraData} Updates the extraData of the current state. {@endtemplate form_bloc.FieldBloc.updateExtraData}
updateFormBloc(FormBloc formBloc, {bool autoValidate = false}) → void
Update the formBloc and autoValidate to the fieldBloc See FieldBloc.updateFormBloc
override
updateInitialValue(Value value) → void
Set value to the value and set isInitial to true of the current state.
updateStateError({required Value value, required Object? error}) → void
updateSuggestions(Suggestions<Suggestion>? suggestions) → void
Updates the suggestions of the current state.
updateValidators(List<Validator<Value>> validators, {bool forceValidation = false}) → void
Updates the current validators with validators.
updateValue(Value value) → void
Set value to the value of the current state.
validate() Future<bool>
Check the value of the current state in each validator and if have an error, the error of the current state will be updated.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited