BloomFileField class
Reactive controller for <input type="file"> file selection fields.
Holds the list of selected BloomFile instances reactively and supports single or multiple selection modes along with dedicated file validators (e.g. maxFileSize, allowedExtensions, allowedMimeTypes, minFiles, maxFiles).
Safe for both browser DOM mounting and SSR rendering.
final avatarField = BloomFileField(
multiple: false,
validators: [
fileRequired('Please choose an avatar image.'),
maxFileSize(2 * 1024 * 1024, 'Avatar must be smaller than 2MB.'),
allowedExtensions(['.png', '.jpg', '.webp']),
],
);
- Implemented types
Constructors
-
BloomFileField({List<
BloomFile> initialValue = const [], bool multiple = false, List<String? Function(List< validators = const [], List<BloomFile> )>Future< asyncValidators = const [], Duration asyncDebounce = const Duration(milliseconds: 300)})String?> Function(List<BloomFile> )> - Creates a reactive file input controller.
Properties
- asyncDebounce → Duration
-
Debounce duration applied when validateAsync is called with
debounce: true.final -
asyncValidators
→ List<
Future< String?> Function(List<BloomFile> )> -
Ordered list of asynchronous validator callbacks evaluated on validateAsync.
final
-
errors
↔ Signal<
List< String> > -
Reactive signal containing validation error messages generated by validate or validateAsync.
latefinaloverride-getter
- file → BloomFile?
-
Convenience getter returning the first selected BloomFile, or
nullif empty.no setter -
files
→ List<
BloomFile> -
Returns the current list of selected files.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
-
isDirty
↔ Signal<
bool> -
Reactive signal indicating whether the file selection has been modified.
latefinaloverride-getter
-
isTouched
↔ Signal<
bool> -
Reactive signal indicating whether the user has interacted with this field.
latefinaloverride-getter
-
isValid
↔ ReadonlySignal<
bool> -
Computed signal that evaluates to
truewhen errors is empty.latefinaloverride-getter -
isValidating
→ ReadonlySignal<
bool> -
Reactive signal indicating whether asynchronous validation is currently executing.
latefinal
- multiple → bool
-
Whether this field accepts multiple files.
final
- rawValue → dynamic
-
Untyped access to the selected files list.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
validators
→ List<
String? Function(List< BloomFile> )> -
Ordered list of synchronous validator callbacks evaluated on validate or validateAsync.
final
-
value
↔ Signal<
List< BloomFile> > -
Reactive signal containing the list of currently selected BloomFile items.
latefinal
Methods
-
clear(
) → void -
Clears all selected files and marks isDirty as
true. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reset(
) → void -
Resets the selected files back to initial value and clears errors, isDirty, and isTouched.
override
-
setFile(
BloomFile? singleFile) → void -
Sets a single selected file (or clears selection if
null) and marks isDirty astrue. -
setFiles(
List< BloomFile> newFiles) → void -
Updates the selected files and marks isDirty as
true. -
toString(
) → String -
A string representation of this object.
inherited
-
touch(
) → void -
Marks isTouched as
trueto indicate user interaction (e.g. on change or blur).override -
validate(
) → bool -
Runs all validators against the current value synchronously and updates errors.
override
-
validateAsync(
{bool debounce = false}) → Future< bool> -
Runs synchronous validators first, and if they pass, evaluates all asyncValidators.
override
-
validateDebounced(
[Duration? delay]) → Future< bool> -
Triggers debounced asynchronous validation using
delayor asyncDebounce.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited