FormCompanionMixin mixin
Extended mixin of CompanionPresenterMixin for vanilla Form.
It is required for submit method that there is a Form widget as an ancestor in BuildContext.
This class supports following features:
- Decouples validation logic from view layer -- validation logic often should exist in domain layer to encourage reuse.
- Async validation handling. This class tracks pending asynchronous
validation logics. The underlying validation infrastructure supports:
- Throttling. If continous validation requests are issued, the validation will only handle last one. FormField often issues continous validation because of such user input like fast text typing as well as repeated validate() calls.
- Caching. Since async validation can be costly and idempotent in most cases, and the result must be same for identical input, so caching validation result reduces latency. It also second guard about continuous validation requests.
- Disables "submit" action. The submit method returns Function when it
is ready for "submit" or
null
otherwise. This class checks validation results of FormFields and existance of pending async validations.
- Superclass constraints
- Available extensions
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
-
presenterFeatures
→ CompanionPresenterFeatures<
FormStateAdapter> -
Do not use this property directly, use methods on
CompanionPresenterMixinExtension instead.
no setteroverride
- propertiesState → FormProperties
-
Gets a current FormProperties which holds properties' values and
their PropertyDescriptors.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
buildOnAsyncValidationCompleted(
String name, BuildContext context) → AsyncValidationCompletionCallback -
Available on CompanionPresenterMixin, provided by the CompanionPresenterMixinExtension extension
Returns completion logic when any async validation is completed. -
canSubmit(
BuildContext context) → bool -
Returns whether the state of this presenter is "completed" or not.
override
-
doSubmit(
) → FutureOr< void> -
Execute "submit" action.
inherited
-
formStateOf(
BuildContext context) → FormStateAdapter -
Available on CompanionPresenterMixin, provided by the CompanionPresenterMixinExtension extension
Gets the ancestor FormState like state from specified BuildContext, and wraps it to FormStateAdapter. -
getKey(
String name, BuildContext context) → Key - Gets a key for specified named field.
-
getLocale(
BuildContext context) → Locale -
Available on CompanionPresenterMixin, provided by the CompanionPresenterMixinExtension extension
Gets current Locale for current BuildContext. -
handleCanceledAsyncValidationError(
AsyncError error) → void -
Available on CompanionPresenterMixin, provided by the CompanionPresenterMixinExtension extension
This method will be called when pending async validation is canceled but the operation throws AsyncError. -
initializeCompanionMixin(
PropertyDescriptorsBuilder properties) → void -
Initializes CompanionPresenterMixin.
You must call this method (or overriden method) in your presenter's
constructor to work mixins correctly.
override
-
maybeFormStateOf(
BuildContext context) → FormStateAdapter? -
Available on CompanionPresenterMixin, provided by the CompanionPresenterMixinExtension extension
Gets the ancestor FormState like state from specified BuildContext, and wraps it to FormStateAdapter. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onPropertiesChanged(
OnPropertiesChangedEvent event) → void -
Called when any property values are changed.
OnPropertiesChangedEvent.newProperties stores new values of the properties.
inherited
-
resetPropertiesState(
FormProperties newProperties) → FormProperties -
Resets propertiesState with specified new FormProperties.
inherited
-
saveFields(
FormStateAdapter formState) → void -
Available on CompanionPresenterMixin, provided by the CompanionPresenterMixinExtension extension
Performs saving of form fields. -
submit(
BuildContext context) → VoidCallback? -
Returns submit callback suitable for
onClick
callback of button which representssubmit
of form.inherited -
toString(
) → String -
A string representation of this object.
inherited
-
validateAll(
FormStateAdapter formState) → FutureOr< bool> -
Available on CompanionPresenterMixin, provided by the CompanionPresenterMixinExtension extension
Do validation for all fields with their all validators including asynchronous ones, and returns FutureOr to await asynchronous validations. -
validateAndSave(
FormStateAdapter formState) → Future< bool> -
Available on CompanionPresenterMixin, provided by the CompanionPresenterMixinExtension extension
Validates all fields' values and then saves them if there is no validation errors.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited