FormState of(BuildContext context)

Returns the closest FormState which encloses the given context.

Typical usage is as follows:

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

Source

static FormState of(BuildContext context) {
  _FormScope scope = context.inheritFromWidgetOfExactType(_FormScope);
  return scope?._formState;
}