you might be getting the compilation error with below code with flutter 2.5

    if (!_formKey.currentState.validate()) {
      // Invalid!
      return;
    }
    _formKey.currentState.save();

Solution:

 final form = _formKey.currentState;
    if (form != null && !form.validate()) {
      // Invalid!
      return;
    }
    form?.save();

Leave a Reply

Your email address will not be published. Required fields are marked *