FormController<T> class abstract

A data form base class. Similar to Form, but adds more support for things like nested forms, validation, etc.

Use one of the static constructors: FormController.singleValue when the form is a single value FormController.ofModel when the form is backed by a single MModel instance FormController.ofMSchema when the form is backed by a MSchemaDefinition FormController.ofMSchemaFuture when the MSchemaDefinition is not loaded yet FormController.ofMap key/value pairs

Mixed-in types
  • Disposable
  • LoggingMixin
Implementers
Available extensions

Constructors

FormController()

Properties

autofocusNode → FocusNode?
Returns the focusNode that should be autofocused based on the current form state. It's generally the first required form field that doesn't have a value
no setter
buildContext → BuildContext
The build context for the form
no setter
errors → SunnyObservableMap<JsonPath, ValidationError?>
An observable map of errors
no setter
formState → SyncStream<SunnyFormState>
A stream of any change to the state of this form.
no setter
hashCode → int
The hash code for this object.
no setterinherited
isModified → bool
Whether the user has made changes to the form.
no setter
lastFocusNode → FocusNode?
The last focus node that was added
no setter
log → Logger
no setterinherited
loggerName → String
no setterinherited
name → String
Helpful for debugging - displays the name of the record being edited, for example
no setter
parent → FormController?
The parent form
no setter
readyChecks → Map<JsonPath, SafeCompleter>
Consumers can request a completer that's used to prevent submission until the child component is ready - maybe they are uploading a file or something.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
stream → Stream<Attribute>
observes changes to all paths
no setter
validators → Map<JsonPath, FormFieldValidator>
Validators run during the validation phase of the submission.
no setter

Methods

addError(JsonPath path, ValidationError? error, {AttributeSource source = AttributeSource.model}) → void
Registers an error at this path
addFocusNode(JsonPath path, FocusNode? node) → void
Adds a focusNode to this form at this path
autofocus([BuildContext? context]) → void
bindCommand<T>(BuildContext context, {FutureOr<T> submit()?, bool? skipIfUnmodified = false}) → void

Available on FormController, provided by the FormControllerCommandExtensions extension

Binds the command - raises an exception if no Command is found
clearError(JsonPath path, {required AttributeSource source}) → void
Removes all errors at this path
clearErrors({required AttributeSource source}) → void
Clears out all errors
dispose() → Future
disposeAll() → Future
inherited
endSubmission() → void
Ends this form's submission process
focusLast([BuildContext? context]) → void
get<X>(JsonPath path) → X?
Retrieves a value from the underlying data model.
getFocusNode(JsonPath path, {bool createIfMissing = true}) → FocusNode?
Retreives a focus node for the specified path
invalidateReadyCheck(JsonPath path) → void
Unregisters a ready check at the given path. (should this also complete any outstanding item?)
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
observePath<X>(JsonPath path) → Stream<X?>
Observes any new values (including null) for a single path
path<X>(JsonPath<X> path, [Attribute<X>? value]) → X?
Retrieves or sets the value from the underlying data model, but uses the type parameter from the JsonPath
pathBuilder<T>(JsonPath path, WidgetValueBuilder<T?> builder) → Widget

Available on FormController, provided by the SunnyControllerWidgetExtensions extension

pathsBuilder<T, T2>(JsonPath first, JsonPath second, WidgetDualValueBuilder<T?, T2?> builder) → Widget

Available on FormController, provided by the SunnyControllerWidgetExtensions extension

put(JsonPath path, dynamic value, {required AttributeSource source}) → void
Put is like set, but it's not assumed that the data has been sanitized
registerDisposer(Disposer callback) → void
inherited
registerForm(FormController? form) → void
Registers a subform
registerFormValidator(String key, FormValidator? validator) → void
Registers a form validator
registerStream(Stream? stream) → void
inherited
registerSubmitHook(String key, SubmitHook? onSubmit) → void
Registers a submit hook. These run after validation
registerSubscription(StreamSubscription? subscription) → void
inherited
removeDisposer(FutureOr dispose()) → void
inherited
requestReadyCheck(JsonPath path) → SafeCompleter
Gets or puts a ready check at the given path
set(JsonPath path, dynamic value, {AttributeSource source = AttributeSource.model}) → void
Sets a value in the underlying model
startSubmission() → void
Begins this forms submission process
submit<X>(BuildContext context, {FutureOr<X?> submit()?, bool? skipIfUnmodified}) → FutureOr<FormSubmitResult<X>>
Submits this form, including subforms, and returns the result
submitIfModified<X>(BuildContext context, [FutureOr<X> submit()?]) → FutureOr<FormSubmitResult<X>>

Available on FormController<T?>, provided by the FormControllerExtensions extension

submitRoot<X>(BuildContext context, {bool? skipIfUnmodified, FutureOr<X>? submit()?}) → FutureOr<FormSubmitResult<X>>

Available on FormController<T?>, provided by the FormControllerExtensions extension

toMetaFormContext(BuildContext context, {Map<String, dynamic>? scope, MetadataOverrides? overrides, List<MetaPropertyHandler>? extraHandlers, FutureOr<IMEntityDefinition>? definition}) → MetaFormContext

Available on FormController, provided by the FormControllerToContext extension

toString() → String
A string representation of this object.
inherited
tryBindCommand<T>(BuildContext context, {FutureOr<T> submit()?, bool? skipIfUnmodified}) → bool

Available on FormController, provided by the FormControllerCommandExtensions extension

unbindCommand<T>(CallBridge<T> command) → void

Available on FormController, provided by the FormControllerCommandExtensions extension

unregisterForm(FormController form) → void
Unregisters a subform
unregisterFormValidator(String key) → void
Unregisters a validator
unregisterSubmitHook(String key) → void
Unregisters a submit hook
updateErrors(List<ValidationError> validationErrors, {required AttributeSource source}) → void
Clears and sets a list of validationErrors
validate({required bool skipIfUnmodified}) → FutureOr<Map<JsonPath, List<ValidationError>>>
Validates this form and any subforms. An empty result means that the form validated successfully
validatePath(JsonPath path) → String?

Operators

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

Static Methods

ofMap(BuildContext context, Map<String, dynamic> map, {Map<JsonPath, FormFieldValidator>? validators, required dynamic name}) → MapForm
ofModel<T extends MBaseModel>(BuildContext context, T model, {Map<JsonPath, FormFieldValidator>? validators}) → MModelForm<T>
ofMSchema<T extends MBaseModel>(BuildContext context, T model, IMSchemaDefinition definition, {Map<JsonPath, FormFieldValidator>? validators}) → FormController
ofMSchemaFuture<T extends MModel>(BuildContext context, T model, {MSchemaRef? mtype, Map<JsonPath, FormFieldValidator>? validators}) → Future<MSchemaForm<T>>
singleValue<T>(BuildContext context, SingleValue<T> container, {Map<JsonPath, FormFieldValidator>? validators, required dynamic name}) → SingleValueForm<T>