StructureBindingController<T> class

A controller that manages the binding between a data structure and Flutter widgets.

This controller handles field validation, error states, and value management for a structured data type T. It provides a way to bind form fields to a data structure while maintaining validation and error handling.

Implemented types
Mixed-in types

Constructors

StructureBindingController(DogStructure structure, DogEngine engine, {Map<String, dynamic> initialValues = const {}})
Creates a new StructureBindingController with the given structure and engine.

Properties

checkErrorStates bool
Controls whether the controller checks for state errors before returning submitted values.
final
classErrorListenable ValueNotifier<AnnotationResult>
A notifier that holds all currently reported class errors.
final
engine DogEngine
The DOGs engine instance used for validation and structure operations.
latefinaloverride-getter
factories List<FlutterWidgetBinder>
A list of widget binders that handle the conversion between data and widgets for each field.
final
fields List<FieldBindingController>
A list of controllers that manage the binding state for each individual field.
final
fieldValueChangeStream Stream<(String, dynamic)>
no setter
hashCode int
The hash code for this object.
no setterinherited
initialValues Map<String, dynamic>
Initial values to populate the controller with when it is first created.
final
metadata Map<Object, Object?>
Returns a read-only map of all metadata entries.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
structure DogStructure
The underlying data structure definition that describes the shape of the data.
final

Methods

addRuntimeError(AnnotationResultLike error) → void
Adds a custom runtime error to the error buffer and recalculates field errors.
clearMeta() → void
Clears all metadata entries.
inherited
field(String name) FieldBindingController
Gets the binding controller for a specific field.
override
getMeta<T>({Object? key, T orElse()?}) → T
Returns the metadata entry for the given key or type argument. If no metadata entry is found, throws an exception or automatically calls the orElse function to initialize the metadata entry and return it.
inherited
getMetaOrNull<T>([Object? key]) → T?
Returns the metadata entry for the given key or type argument. If no metadata entry is found, returns null.
inherited
load(T value) → void
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyFieldValue(String fieldName, dynamic fieldValue) → void
Notifies the controller of a field value change.
override
read(bool silent) → T?
Reads the current state of all fields.
rebindField(String fieldName, FlutterWidgetBinder binder) → void
Rebinds a field to use a different widget binder.
requestFieldValidation(String fieldName, dynamic fieldValue) → void
Requests validation for a specific field. The result of the validation will be pushed to the field's ValueNotifier.
override
reset() → void
Resets the state of all fields in this controller, loading the initial values.
runValidation(ValidationTrigger? trigger) → (bool, T?)
setInitialValues(Map<String, dynamic> values) → void
Sets the initial values for the fields in this controller.
setMeta<T>(T value, {Object? key}) → void
Sets the metadata entry for the given key or type argument.
inherited
submit() → T?
swapController(String fieldName, FieldBindingController controller, {FlutterWidgetBinder? binder}) → void
Swaps out a field's binding controller with a new one while preserving its current value.
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

create<T>({Map<String, dynamic>? initialValues, T? initialValue, DogEngine? engine}) StructureBindingController<T>
Creates a new StructureBindingController for type T.
schema({required SchemaType schema, DogEngine? engine, Map<String, dynamic>? initialValue}) StructureBindingController
Creates a new StructureBindingController from a SchemaType.