GFormController class final
Coordinates a Flutter Form and named text controllers.
This is intentionally small: it handles the repetitive form key, validate/save/reset flow, and controller disposal for forms that do not need a larger state-management solution.
- Inheritance
-
- Object
- ChangeNotifier
- GFormController
Constructors
-
GFormController({GlobalKey<
FormState> ? key}) -
Creates a controller. Pass an existing
keyto reuse a form key, or omit it to have one created automatically.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
-
key
→ GlobalKey<
FormState> -
The GlobalKey attached to the underlying Flutter Form.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- state → FormState?
-
The current FormState, or
nullif the form has not been mounted yet.no setter - submitting → bool
-
Whether submit is currently in flight.
no setter
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
dispose(
) → void -
Discards any resources used by the object.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
reset(
) → void - Resets the form and clears every registered text controller.
-
save(
) → void -
Calls
onSavedon every field. -
submit(
FutureOr< void> onSubmit(Map<String, String> values), {bool resetOnSuccess = false}) → Future<bool> -
Validates, saves, and runs
onSubmitwith the current text values. -
text(
String name) → String -
Current text of the controller registered under
name. -
textController(
String name, {String? text}) → TextEditingController -
Returns the TextEditingController registered under
name, creating one withtextas its initial value if it doesn't exist yet. -
textValues(
) → Map< String, String> - Snapshot of every registered field's current text, keyed by name.
-
toString(
) → String -
A string representation of this object.
inherited
-
validate(
) → bool -
Runs every registered validator. Returns
trueif the form is valid. -
validateAndSave(
) → bool - Validates the form and, if valid, calls save. Returns whether the form was valid.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited