FormBloc<SuccessResponse, FailureResponse> class
abstract
The base class for all FormBlocs
.
See complex examples here: https://github.com/allenlinli/form_bloc/tree/master/packages/flutter_form_bloc/example/lib/forms
- Inheritance
-
- Object
- BlocBase<
FormBlocState< SuccessResponse, FailureResponse> > - Cubit<
FormBlocState< SuccessResponse, FailureResponse> > - FormBloc
Constructors
- FormBloc.new({bool isLoading = false, bool autoValidate = true, bool isEditing = false})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isClosed → bool
-
Whether the bloc is closed.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
state
→ FormBlocState<
SuccessResponse, FailureResponse> -
The current state.
no setterinherited
-
stream
→ Stream<
FormBlocState< SuccessResponse, FailureResponse> > -
The current stream of states.
no setterinherited
Methods
-
addError(
Object error, [StackTrace? stackTrace]) → void -
Reports an
error
which triggers onError with an optional StackTrace.inherited -
addFieldBloc(
{int step = 0, required FieldBloc< FieldBlocStateBase> fieldBloc}) → void -
Adds
fieldBloc
to the FormBloc. -
addFieldBlocs(
{int step = 0, required List< FieldBloc< fieldBlocs}) → voidFieldBlocStateBase> > -
Adds
fieldBlocs
to the FormBloc. -
cancelSubmission(
) → void -
Call onCancelingSubmission if state is FormBlocSubmitting
and FormBlocSubmitting.isCanceling is
false
. -
clear(
) → void -
Call
clear
method for each FieldBloc inFieldBlocs
. -
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
-
delete(
) → void - Call onDeleting and set the current state to FormBlocDeleting.
-
emit(
FormBlocState< SuccessResponse, FailureResponse> state) → void -
Updates the
state
to the providedstate
. emit does nothing if thestate
being emitted is equal to the currentstate
.inherited -
emitDeleteFailed(
{FailureResponse? failureResponse}) → void - Update the state of the form bloc to FormBlocDeleteFailed.
-
emitDeleteSuccessful(
{SuccessResponse? successResponse}) → void - Update the state of the form bloc to FormBlocDeleteSuccessful.
-
emitFailure(
{FailureResponse? failureResponse}) → void - Update the state of the form bloc to FormBlocFailure.
-
emitLoaded(
{SuccessResponse? successResponse}) → void - Update the state of the form bloc to FormBlocLoaded.
-
emitLoadFailed(
{FailureResponse? failureResponse}) → void - Update the state of the form bloc to FormBlocLoadFailed.
-
emitLoading(
{double progress = 0.0}) → void - Update the state of the form bloc to FormBlocLoading.
-
emitSubmissionCancelled(
) → void - Update the state of the form bloc to FormBlocSubmissionCancelled.
-
emitSubmitting(
{double? progress}) → void - Update the state of the form bloc to FormBlocSubmitting.
-
emitSuccess(
{SuccessResponse? successResponse, bool? canSubmitAgain, bool? isEditing}) → void - Update the state of the form bloc to FormBlocSuccess.
-
emitUpdatingFields(
{double? progress}) → void -
Update the state of the form bloc
to
FormUpdatingFields
. -
hasInitialValues(
{int? step}) → bool - Check if all field blocs and their children have initial values
-
hasUpdatedValues(
{int? step}) → bool - Check if all field blocs and their children have updated values
-
isValuesChanged(
{int? step}) → bool - Check if all field blocs and their children have undergone a change in values
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onCancelingSubmission(
) → FutureOr< void> -
This method is called when the FormBlocState
is FormBlocSubmitting and
CancelSubmissionFormBloc
is dispatched. -
onChange(
Change< FormBlocState< change) → voidSuccessResponse, FailureResponse> > -
Called whenever a
change
occurs with the givenchange
. Achange
occurs when a newstate
is emitted. onChange is called before thestate
of thecubit
is updated. onChange is a great spot to add logging/analytics for a specificcubit
.inherited -
onDeleting(
) → FutureOr< void> - This method is called when delete is called.
-
onError(
Object error, StackTrace stackTrace) → void -
Called whenever an
error
occurs and notifies BlocObserver.onError.inherited -
onLoading(
) → FutureOr< void> -
This method is called when the FormBloc
is instantiated and
isLoading
istrue
. -
onSubmitting(
) → FutureOr< void> -
This method is called when FormBlocState.isValid is
true
and submit was called and FormBlocState.canSubmit istrue
. -
previousStep(
) → void -
reload(
) → void - Call onLoading and set the current state to FormBlocLoading.
-
removeFieldBloc(
{int? step, required FieldBloc< FieldBlocStateBase> fieldBloc}) → void - Removes a FieldBloc from the FormBloc
-
removeFieldBlocs(
{int? step, required List< FieldBloc< fieldBlocs}) → voidFieldBlocStateBase> > -
Removes a
FieldBlocs
from the FormBloc -
submit(
) → void -
Submit the form, if FormBlocState.canSubmit is
true
andFormBlocState._isValidByStep
istrue
onSubmitting will be called. -
toString(
) → String -
A string representation of this object.
override
-
updateCurrentStep(
int step) → void -
Update FormBlocState.currentStep only if
step
is valid by calling FormBlocState.isValid
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited