BlocxFormRegisterButton<F extends BlocxBaseFormEntity<F, E> , P, E extends Enum> class
A reusable submit button that reacts to the current BlocxFormState.
Automatically handles three visual states:
- Idle — shows buttonText and calls onPressed (or the ancestor
form's
submit) when tapped. - Submitting — disables the button, swaps the label to submitText, and shows a loading indicator.
- Checking unique fields — disables the button and shows a loading indicator while async field validation is in progress.
- Has errors — disables the button until all form errors are resolved.
Visual variants
Choose a Material style via type. Each variant can be individually
styled via its corresponding *Style parameter, or with the unified
style shorthand (takes precedence).
Custom variants
Extend this class and override buildOtherButton to provide a fully custom look (e.g. glassmorphic, neumorphic, or Cupertino-style buttons) while retaining all the built-in state management.
Example
BlocxFormRegisterButton(
state: state,
buttonText: 'Sign Up',
submitText: 'Signing up...',
onPressed: null, // uses the ancestor form's submit by default
)
See also:
- BlocxFormWidget, which provides the ancestor form state.
- RegisterButtonType, for the available visual variants.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- BlocxStatelessWidget
- BlocxFormRegisterButton
Constructors
-
BlocxFormRegisterButton({Key? key, required BlocxFormState<
dynamic, Enum> state, required String buttonText, required String submitText, required VoidCallback? onPressed, RegisterButtonType type = RegisterButtonType.filled, ButtonStyle? elevatedStyle, ButtonStyle? filledStyle, ButtonStyle? textStyle, ButtonStyle? outlinedStyle, TextStyle? labelTextStyle, WidgetBuilder? loadingIndicatorBuilder, double spacing = 8.0, ButtonStyle? style}) -
Creates a BlocxFormRegisterButton.
const
Properties
-
The label displayed when the form is idle.
final
- elevatedStyle → ButtonStyle?
-
Optional style applied to RegisterButtonType.elevated buttons.
final
- filledStyle → ButtonStyle?
-
Optional style applied to RegisterButtonType.filled buttons.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isCheckingFields → bool
-
Whether any fields are currently being validated asynchronously.
no setter
- isSubmittingForm → bool
-
Whether the form is currently submitting.
no setter
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- labelTextStyle → TextStyle?
-
Optional style applied to the inner Text label.
final
- loadingIndicatorBuilder → WidgetBuilder?
-
Builds a custom loading indicator shown while submitting or checking fields.
final
- onPressed → VoidCallback?
-
Called when the button is tapped while idle.
final
- outlinedStyle → ButtonStyle?
-
Optional style applied to RegisterButtonType.outlined buttons.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- spacing → double
-
Horizontal spacing between the loading indicator and the label text.
final
-
state
→ BlocxFormState<
dynamic, Enum> -
The current form state, used to determine whether the button should be
disabled and which label to display.
final
- style → ButtonStyle?
-
A unified ButtonStyle that takes precedence over all per-type style
parameters (elevatedStyle, filledStyle, textStyle, outlinedStyle).
final
- submitText → String
-
The label displayed while the form is submitting.
final
- textStyle → ButtonStyle?
-
Optional style applied to RegisterButtonType.text buttons.
final
- type → RegisterButtonType
-
The visual variant of the button.
final
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
buildElevatedButton(
BuildContext context, {required String label, required bool disabled}) → Widget - Builds an ElevatedButton variant.
-
buildFilledButton(
BuildContext context, {required String label, required bool disabled}) → Widget - Builds a FilledButton (Material 3) variant.
-
buildOtherButton(
BuildContext context, {required String label, required bool disabled}) → Widget - Builds a fully custom button variant.
-
buildOutlinedButton(
BuildContext context, {required String label, required bool disabled}) → Widget - Builds an OutlinedButton variant.
-
buildTextButton(
BuildContext context, {required String label, required bool disabled}) → Widget - Builds a TextButton variant.
-
colorScheme(
BuildContext context) → ColorScheme -
inherited
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
getState(
BuildContext context) → BlocxFormWidgetState< BlocxFormWidget< P> , F, P, E> - Retrieves the nearest ancestor BlocxFormWidgetState from the widget tree.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
textTheme(
BuildContext context) → TextTheme -
inherited
-
theme(
BuildContext context) → ThemeData -
inherited
-
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
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited