TextFieldBloc<ExtraData> class
A FieldBloc used for String type, but generally
it is also used to obtain int and double values
of texts thanks to the methods
valueToInt and valueToDouble.
- Inheritance
-
- Object
- BlocBase<
TextFieldBlocState< ExtraData?> > - Cubit<
TextFieldBlocState< ExtraData?> > - SingleFieldBloc<
String, String, TextFieldBlocState< ExtraData?> , ExtraData?> - TextFieldBloc
Constructors
-
TextFieldBloc({String? name, String initialValue = '', List<
Validator< ? validators, List<String> >AsyncValidator< ? asyncValidators, Duration asyncValidatorDebounceTime = const Duration(milliseconds: 500), Suggestions<String> >String> ? suggestions, ExtraData? extraData}) -
TextFieldBloc<ExtraData>
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasInitialValue → bool
-
Indicate if this field has value from
FieldBloc.updateInitialValuemethod. FieldBlocState.hasInitialValueno setterinherited - hasUpdatedValue → bool
-
Indicate if this field has value from
FieldBloc.updateValuemethod. FieldBlocState.hasUpdatedValueno setterinherited - isClosed → bool
-
Whether the bloc is closed.
no setterinherited
- isValueChanged → bool
-
Returns true when the value has been changed by
FieldBloc.changeValue. FieldBlocState.isValueChangedno setterinherited - name → String
-
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
selectedSuggestion
→ Stream<
String> -
Returns Stream of selected
Suggestions.no setterinherited -
state
→ TextFieldBlocState<
ExtraData?> -
The current state.
no setterinherited
-
stream
→ Stream<
TextFieldBlocState< ExtraData?> > -
The current stream of states.
no setterinherited
- value → String
-
Returns the
valueof the current state.no setterinherited - valueToDouble → double?
-
Return the parsed
valuetodoubleof the current state.no setter - valueToInt → int?
-
Return the parsed
valuetointof the current state.no setter
Methods
-
addAsyncValidators(
List< AsyncValidator< asyncValidators, {bool forceValidation = false}) → voidString> > -
Add
asyncValidatorsto the currentvalidatorsfor check ifvalueof the current state has an error.inherited -
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.inherited -
addValidators(
List< Validator< validators, {bool forceValidation = false}) → voidString> > -
Add
validatorsto the currentvalidatorsfor check ifvalueof the current state has an error.inherited -
changeValue(
String value) → void -
inherited
-
clear(
) → void -
Set the
valuetoinitialValueof the current state.inherited -
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.
inherited
-
emit(
TextFieldBlocState< ExtraData?> 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< TextFieldBlocState< change) → voidExtraData?> > -
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(TextFieldBlocState< ExtraData?> previous, TextFieldBlocState<ExtraData?> current)?, required Stream<R> onData(TextFieldBlocState<ExtraData?> previous, TextFieldBlocState<ExtraData?> current), void onFinish(TextFieldBlocState<ExtraData?> previous, TextFieldBlocState<ExtraData?> current, R result)?}) → StreamSubscription -
Returns a
`StreamSubscription<R>`,inherited -
removeAsyncValidators(
List< AsyncValidator< asyncValidators, {bool forceValidation = false}) → voidString> > -
Add
asyncValidatorsto the currentvalidatorsfor check ifvalueof the current state has an error.inherited -
removeFormBloc(
FormBloc formBloc) → void -
Remove the
formBlocto the fieldBloc See FieldBloc.removeFormBlocinherited -
removeValidators(
List< Validator< validators, {bool forceValidation = false}) → voidString> > -
Add
validatorsto the currentvalidatorsfor check ifvalueof the current state has an error.inherited -
resetStateIsValidated(
) → void -
inherited
-
selectSuggestion(
String suggestion) → void -
Add a
suggestionto selectedSuggestion.inherited -
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.inherited -
toString(
) → String -
A string representation of this object.
inherited
-
updateAsyncValidators(
List< AsyncValidator< asyncValidators, {bool forceValidation = false}) → voidString> > -
Updates the current
asyncValidatorswithasyncValidators.inherited -
updateExtraData(
ExtraData? extraData) → void -
Updates the
extraDataof the current state.inherited -
updateFormBloc(
FormBloc formBloc, {bool autoValidate = false}) → void -
Update the
formBlocandautoValidateto the fieldBloc See FieldBloc.updateFormBlocinherited -
updateInitialValue(
String value) → void -
Set
valueto thevalueand setisInitialtotrueof the current state.inherited -
updateStateError(
{required String value, required Object? error}) → void -
inherited
-
updateSuggestions(
Suggestions< String> ? suggestions) → void -
Updates the
suggestionsof the current state.inherited -
updateValidators(
List< Validator< validators, {bool forceValidation = false}) → voidString> > -
Updates the current
validatorswithvalidators.inherited -
updateValue(
String value) → void -
Set
valueto thevalueof the current state.inherited -
validate(
) → Future< bool> -
Check the value of the current state in each
validatorand if have an error, theerrorof the current state will be updated.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited