BlocxFormWidgetState<W extends BlocxFormWidget<P>, F extends BlocxBaseFormEntity<F, E>, P, E extends Enum> class abstract

Base state class for screens that host a BlocxFormBloc.

Extends BlocxScreenManagerState so all screen-manager side-effects (snackBars, error pages, pop) are handled automatically.

Minimal implementation

  1. Create a BlocxFormWidget subclass that carries the payload P.
  2. Extend BlocxFormWidgetState with the matching type parameters.
  3. Implement generateBloc to instantiate the bloc.
  4. Implement formWidget to build the form UI from the current state.
  5. Implement keys to list every field enum value that has a TextEditingController (used for applyInitialDataToForm).
class LoginScreenState
    extends BlocxFormWidgetState<LoginScreen, LoginForm, void, LoginField> {
  @override
  BlocxFormBloc<LoginForm, void, LoginField> generateBloc() => LoginBloc();

  @override
  Widget formWidget(BuildContext context, BlocxFormState<LoginForm, LoginField> state) {
    return Column(children: [
      textField(LoginField.email),
      textField(LoginField.password),
      BlocxFormRegisterButton(state: state, buttonText: 'Login', submitText: 'Logging in…', onPressed: submit),
    ]);
  }

  @override
  List<LoginField> get keys => LoginField.values;
}

Type parameters

  • W: The BlocxFormWidget subclass this state belongs to.
  • F: The immutable form entity. Must extend BlocxBaseFormEntity.
  • P: The optional payload type for edit/update forms. Use void for create-only forms.
  • E: The field enum type.
Inheritance

Constructors

BlocxFormWidgetState()

Properties

autoCloseBloc bool
Whether bloc is closed when this state is disposed. Defaults to true.
no setter
autovalidateMode AutovalidateMode
The auto-validate mode passed to form fields. Defaults to AutovalidateMode.onUserInteraction.
no setter
bloc ↔ BlocxFormBloc<F, P, E>
The form bloc that drives this screen.
latefinal
colorScheme ColorScheme
no setterinherited
context BuildContext
The location in the tree where this widget builds.
no setterinherited
formVerticalSpacing double
Vertical spacing between form fields. Defaults to 16.
no setter
hashCode int
The hash code for this object.
no setterinherited
height double
no setterinherited
isUpdate bool
Whether this screen is in update/edit mode (payload is non-null).
no setter
isValid bool
Whether the current form state passes all validation rules.
no setter
keys List<E>
The list of field enum values that have managed TextEditingControllers.
no setter
managerCubit → ScreenManagerCubit
The ScreenManagerCubit that drives this screen's side-effects.
no setter
mounted bool
Whether this State object is currently in a tree.
no setterinherited
payload → P?
The current widget payload, if any.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
state → BlocxFormState<dynamic, Enum>
The current form state.
no setter
textTheme TextTheme
no setterinherited
theme ThemeData
no setterinherited
widget → W
The current configuration.
no setterinherited
width double
no setterinherited
wrapInScaffold bool
Whether the body should be wrapped in a Scaffold.
no setterinherited

Methods

activate() → void
Called when this object is reinserted into the tree after having been removed via deactivate.
inherited
applyInitialDataToForm(F formData) → void
Hydrates TextEditingControllers from formData after init.
blocListener(BuildContext context, BlocxFormState<F, E> state) → void
Reacts to listen-only form states.
build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
inherited
changeListener(dynamic data, E key) → void
Dispatches a field update event for key with data.
checkbox({required E key, required bool isChecked, BlocxCheckboxOptions? options}) → BlocxFormCheckbox<F, P, E>
Builds a BlocxFormCheckbox pre-wired to key.
clearFieldError(E key, {String? message}) → void
Clears the error for key.
deactivate() → void
Called when this object is removed from the tree.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
decorateScaffold(Widget scaffold) Widget
Hook to decorate the scaffold returned by scaffoldWidget.
inherited
didChangeDependencies() → void
Called when a dependency of this State object changes.
inherited
didUpdateWidget(covariant W oldWidget) → void
Called whenever the widget configuration changes.
inherited
displaySnackBar(BuildContext context, String message, String? title, BlocXSnackbarType snackbarType) → void
Shows a BlocxSnackBar with the given parameters.
inherited
dispose() → void
Called when this object is removed from the tree permanently.
override
Builds a BlocXFormDropdown pre-wired to key.
errorWidget(BuildContext context, ScreenManagerCubitStateDisplayErrorPage state) Widget
Builds the full-page error widget for ScreenManagerCubitStateDisplayErrorPage.
inherited
errorWidgetByErrorCode(BuildContext context, ScreenManagerCubitStateDisplayErrorPageByErrorCode state) Widget
Builds the full-page error widget for ScreenManagerCubitStateDisplayErrorPageByErrorCode.
inherited
formWidget(BuildContext context, BlocxFormState<F, E> state) → dynamic
Builds the form UI from the current state.
generateBloc() → BlocxFormBloc<F, P, E>
Instantiates the BlocxFormBloc for this screen.
getFocusNode(E key) FocusNode
Returns the FocusNode for key, creating one if needed.
getTextEditingController(E key) TextEditingController
Returns the TextEditingController for key, creating one if needed.
initState() → void
Called when this object is inserted into the tree.
mainWidget(BuildContext context, ScreenManagerCubitState state) Widget
The primary screen content.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onFormSubmitted(BlocxFormStateFormSubmitted<F, E> state) → void
Called when BlocxFormStateFormSubmitted is emitted.
onFormUpdated(F formData) → void
Called when BlocxFormStateFormUpdated is emitted.
reassemble() → void
Called whenever the application is reassembled during debugging, for example during hot reload.
inherited
scaffoldWidget(BuildContext context, Widget body) Widget
Wraps body in a Scaffold.
inherited
setErrorToField(E key, String message) → void
Manually sets a validation error on key with message.
setState(VoidCallback fn) → void
Notify the framework that the internal state of this object has changed.
inherited
setTimedErrorToField(E key, String message, {Duration? duration}) → void
Sets a timed validation error on key that auto-clears after duration.
submit() → void
Dispatches BlocxFormEventSubmit to the bloc.
textField(E key, {BlocXTextFieldOptions? options, FormFieldValidator? validator, TextFieldType? type}) BlocXFormTextField<F, P, E>
Builds a BlocXFormTextField pre-wired to key.
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringShort() String
A brief description of this object, usually just the runtimeType and the hashCode.
inherited

Operators

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