of method

FormState of (
  1. BuildContext context
)

Returns the closest FormState which encloses the given context.

Typical usage is as follows:

FormState form = Form.of(context);
form.save();

Implementation

static FormState of(BuildContext context) {
  final _FormScope scope = context.dependOnInheritedWidgetOfExactType<_FormScope>();
  return scope?._formState;
}