I'm trying to save the form on a button click but it is giving me an error that the "method can not be called because the receiver can be null". I'm providing a null check but the error is not getting solved. Any help would be greatly appreciated.
Here is the code
onPressed: () {
if (_formKey.currentState != null) {
_formKey.currentState.save(); // this gives the error
}
},
This onPressed is linked with the elevated button and the _formKey here is this:
// key to work with the form
final _formKey = GlobalKey<FormState>();