BloomForm class
Reactive controller for a collection of named form controls.
Coordinates cross-field validation, dirty tracking, submission lifecycle, and form reset operations across mixed field types (strings, numbers, booleans, files, field arrays, and nested sub-forms).
Submission Lifecycle
Calling submit or submitRaw executes the following sequence:
- Runs validateAsync across all registered controls and awaits completion.
- If any control fails validation, submission halts immediately and callback is not called.
- If validation succeeds, isSubmitting is set to
true. - Awaits the callback with a snapshot of values.
- In a
finallyblock, resets isSubmitting back tofalse.
final profileForm = BloomForm({
'username': BloomFormField(validators: [required(), minLength(3)]),
'age': BloomTypedFormField<int>(initialValue: 25, validators: [min(18)]),
'avatar': BloomFileField(validators: [fileRequired()]),
'agree': BloomTypedFormField<bool>(initialValue: false, validators: [requiredTrue()]),
'skills': BloomFieldArray<BloomFormField>(
initialValues: [BloomFormField(initialValue: 'Dart')],
),
});
await profileForm.submitRaw((data) async {
print('Submitted data: $data');
});
Constructors
-
BloomForm(Map<
String, BloomFormControl> fields) -
Creates a BloomForm controller managing the provided map of named
fields.
Properties
-
data
→ Map<
String, dynamic> -
Alias for rawValues returning the structured values of all registered fields.
no setter
-
fields
→ Map<
String, BloomFormControl> -
Map of all registered controls in the form.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
-
isDirty
↔ ReadonlySignal<
bool> -
Computed signal returning
truewhen at least one registered field's BloomFormControl.isDirty istrue.latefinal -
isSubmitting
→ Signal<
bool> -
Reactive signal indicating whether an asynchronous submit handler is currently running.
final
-
isValid
↔ ReadonlySignal<
bool> -
Computed signal returning
truewhen every registered field's BloomFormControl.isValid istrue.latefinal -
isValidating
↔ ReadonlySignal<
bool> -
Computed signal returning
truewhen any registered field's BloomFormControl.isValidating istrue.latefinal -
rawValues
→ Map<
String, dynamic> -
Returns a structured map containing untyped/raw values of all registered fields.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
values
→ Map<
String, String> -
Returns a snapshot map of all current field string values keyed by field name.
no setter
Methods
-
getControl<
T extends BloomFormControl> (String name) → T -
Returns the registered control under
nametyped asT. -
getField(
String name) → BloomFormField -
Returns the BloomFormField registered under
name. -
getValue(
String name) → String -
Returns the current string value of the field registered under
name. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reset(
) → void - Resets all registered fields to their initial values and clears isSubmitting.
-
submit(
Future< void> onSubmit(Map<String, String> values)) → Future<void> -
Validates all fields asynchronously and executes
onSubmitif validation succeeds. -
submitAsync(
Future< void> onSubmit(Map<String, String> values)) → Future<void> - Asynchronous counterpart to submit.
-
submitData(
Future< void> onSubmit(Map<String, dynamic> values)) → Future<void> - Alias for submitRaw taking structured values.
-
submitDataAsync(
Future< void> onSubmit(Map<String, dynamic> values)) → Future<void> - Asynchronous counterpart to submitData.
-
submitRaw(
Future< void> onSubmit(Map<String, dynamic> values)) → Future<void> -
Validates all fields asynchronously and executes
onSubmitwith structured rawValues if validation succeeds. -
submitRawAsync(
Future< void> onSubmit(Map<String, dynamic> values)) → Future<void> - Asynchronous counterpart to submitRaw.
-
toString(
) → String -
A string representation of this object.
inherited
-
touch(
) → void - Marks all registered fields as touched.
-
validate(
) → bool -
Runs
validate()on every registered field synchronously. -
validateAsync(
{bool debounce = false}) → Future< bool> - Runs asynchronous validation across all registered controls concurrently.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited