maybeOf static method
- BuildContext context
Returns the FormState of the closest Form widget which encloses the given context, or null if none is found.
Typical usage is as follows:
FormState? form = Form.maybeOf(context);
form?.save();
Calling this method will create a dependency on the closest Form in the
context
, if there is one.
See also:
Implementation
static FormState? maybeOf(BuildContext context) {
final _FormScope? scope = context.dependOnInheritedWidgetOfExactType<_FormScope>();
return scope?._formState;
}