FieldSelector<T> class
A widget that rebuilds whenever a selected value from a FieldController changes.
The FieldSelector is a specialized version of FormySelector that
observes a FieldController and rebuilds only when the selected
portion of the field state (defined by the selector
) changes.
This is useful to optimize performance by avoiding rebuilds when unrelated parts of the field change.
Properties
- controller: The FieldController being observed.
- selector: Function that extracts the value to watch from the field.
- child: Builder that receives the selected value.
Example
FieldSelector<bool>(
controller: myField,
selector: (field) => field.valid,
child: (isValid) => Icon(
isValid ? Icons.check : Icons.close,
color: isValid ? Colors.green : Colors.red,
),
)
See also
- FieldController, which manages individual field state.
- FormySelector, the generic base class that this widget extends.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- FormySelector<
FieldController, T> - FieldSelector
Constructors
- FieldSelector.new({Key? key, required FieldController controller, required T selector(FieldController value), required Widget child(T value)})
-
Creates a FieldSelector.
const
Properties
- child → Widget Function(T value)
-
Builder function that receives the selected value.
finalinherited
- controller → FieldController
-
The controller being observed.
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- selector → T Function(FieldController value)
-
Function that selects the data to watch from the controller.
finalinherited
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< FieldSelector< T> > -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited