of method

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();

Implementation

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