Answers for "The method 'validate' can't be unconditionally invoked because the receiver can be 'null'. Try making the call conditional (using '?.') or adding a null check to the target ('!')."

0

The method 'validate' can't be unconditionally invoked because the receiver can be 'null'. Try making the call conditional (using '?.') or adding a null check to the target ('!').

/* dart 2.0 must implement null safety, try add use safe calls "?" 
when declaring variable or use null check operator "!" behind object
*/

 bool validate() {
    bool status = false;
    final form = formKey.currentState;
    form?.save();
    if (form!.validate()) {
      form.save();
      status = true;
    } else {
      status = false;
    }
    return status;
  }
Posted by: Guest on July-22-2021

Code answers related to "The method 'validate' can't be unconditionally invoked because the receiver can be 'null'. Try making the call conditional (using '?.') or adding a null check to the target ('!')."

Code answers related to "Dart"

Browse Popular Code Answers by Language