SingleFieldBloc<Value, Suggestion, State extends FieldBlocState<Value, Suggestion, ExtraData> , ExtraData> class
abstract
The base class with the common behavior of all single field blocs:
Constructors
-
SingleFieldBloc({Equality<
Value> equality = const DefaultEquality<Never>(), required List<Validator< ? validators, required List<Value> >AsyncValidator< ? asyncValidators, required Duration asyncValidatorDebounceTime, required State initialState})Value> >
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasInitialValue → bool
-
Indicate if this field has value from
FieldBloc.updateInitialValuemethod. FieldBlocState.hasInitialValueno setter - hasUpdatedValue → bool
-
Indicate if this field has value from
FieldBloc.updateValuemethod. FieldBlocState.hasUpdatedValueno setter - isClosed → bool
-
Whether the bloc is closed.
no setterinherited
- isValueChanged → bool
-
Returns true when the value has been changed by
FieldBloc.changeValue. FieldBlocState.isValueChangedno 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
valueof the current state.no setter
Methods
-
addAsyncValidators(
List< AsyncValidator< asyncValidators, {bool forceValidation = false}) → voidValue> > -
Add
asyncValidatorsto the currentvalidatorsfor check ifvalueof the current state has an error. -
addError(
Object error, [StackTrace? stackTrace]) → void -
Reports an
errorwhich triggers onError with an optional StackTrace.inherited -
addFieldError(
Object error, {bool isPermanent = false}) → void -
If
isPermanentisfalse, add an error to FieldBlocState.error. -
addValidators(
List< Validator< validators, {bool forceValidation = false}) → voidValue> > -
Add
validatorsto the currentvalidatorsfor check ifvalueof the current state has an error. -
changeValue(
Value value) → void -
clear(
) → void -
Set the
valuetoinitialValueof 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.
override
-
emit(
State state) → void -
Updates the
stateto the providedstate. emit does nothing if thestatebeing emitted is equal to the currentstate.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onChange(
Change< State> change) → void -
Called whenever a
changeoccurs with the givenchange. Achangeoccurs when a newstateis emitted. onChange is called before thestateof thecubitis updated. onChange is a great spot to add logging/analytics for a specificcubit.inherited -
onError(
Object error, StackTrace stackTrace) → void -
Called whenever an
erroroccurs 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< asyncValidators, {bool forceValidation = false}) → voidValue> > -
Add
asyncValidatorsto the currentvalidatorsfor check ifvalueof the current state has an error. -
removeFormBloc(
FormBloc formBloc) → void -
Remove the
formBlocto the fieldBloc See FieldBloc.removeFormBlocoverride -
removeValidators(
List< Validator< validators, {bool forceValidation = false}) → voidValue> > -
Add
validatorsto the currentvalidatorsfor check ifvalueof the current state has an error. -
resetStateIsValidated(
) → void -
selectSuggestion(
Suggestion suggestion) → void -
Add a
suggestionto selectedSuggestion. -
subscribeToFieldBlocs(
List< FieldBloc< fieldBlocs) → voidFieldBlocStateBase> > -
Create a subscription to the state of each
fieldBlocinFieldBlocs, When any state changes, thisfieldBlocwill be revalidated. This is useful when you havevalidatorsthat uses the state of otherfieldBloc, for example when you want the correct behavior of validator that confirms a password with the password of otherfieldBloc. -
toString(
) → String -
A string representation of this object.
override
-
updateAsyncValidators(
List< AsyncValidator< asyncValidators, {bool forceValidation = false}) → voidValue> > -
Updates the current
asyncValidatorswithasyncValidators. -
updateExtraData(
ExtraData extraData) → void -
Updates the
extraDataof the current state. -
updateFormBloc(
FormBloc formBloc, {bool autoValidate = false}) → void -
Update the
formBlocandautoValidateto the fieldBloc See FieldBloc.updateFormBlocoverride -
updateInitialValue(
Value value) → void -
Set
valueto thevalueand setisInitialtotrueof the current state. -
updateStateError(
{required Value value, required Object? error}) → void -
updateSuggestions(
Suggestions< Suggestion> ? suggestions) → void -
Updates the
suggestionsof the current state. -
updateValidators(
List< Validator< validators, {bool forceValidation = false}) → voidValue> > -
Updates the current
validatorswithvalidators. -
updateValue(
Value value) → void -
Set
valueto thevalueof the current state. -
validate(
) → Future< bool> -
Check the value of the current state in each
validatorand if have an error, theerrorof the current state will be updated.override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited