title: Unhandled Exception: type '(String, int) => Future<Null>' is not a subtype of type '(String, int?) => void' in type cast
body: <p>Need help to solve this problem, i got stuck with this when running my code. it keeps on showing this error Unhandled Exception: type '(String, int) =&gt; Future' is not a subtype of type '(String, int?) =&gt; void' in type cast.. i tried solving this to no avail, i went to various forums and i saw different ideas which didnt work for. i hope someone can help me out here.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>class AuthProvider with ChangeNotifier {
  
    FirebaseAuth _auth = FirebaseAuth.instance;
    late String smsOtp;
    late String verificationId;
    String error = '';
    UserServices _userServices = UserServices();
  
    Future &lt; void &gt; verifyPhone(BuildContext context, String number) async {
      final PhoneVerificationCompleted verificationCompleted =
        (PhoneAuthCredential credential) async {
          await _auth.signInWithCredential(credential);
        };
  
      final PhoneVerificationFailed verificationFailed = (FirebaseAuthException e) {
        print(e.code);
      };
  
      final PhoneCodeSent smsOtpSend = (String verId, int resendToken) async {
        this.verificationId = verId;
      }
      as PhoneCodeSent;
  
      smsOtpDialog(context, number);
  
      try {
        _auth.verifyPhoneNumber(
          phoneNumber: number,
          verificationCompleted: verificationCompleted,
          verificationFailed: verificationFailed,
          codeSent: smsOtpSend,
          codeAutoRetrievalTimeout: (String verId) {
            this.verificationId = verId;
          },
        );
  
      } catch (e) {
        print(e);
      }
    }
  
    Future &lt; bool ? &gt; smsOtpDialog(BuildContext context, String number) {
      return showDialog(
        context: context,
        builder: (BuildContext context) {
          return AlertDialog(
            title: Column(
              children: [
                Text('Verification Code'),
                SizedBox(height: 6, ),
                Text('Enter the 6 didgit Code received by sms',
                  style: TextStyle(color: Colors.grey, fontSize: 10),
                ),
              ],
            ),
            content: Container(
              height: 85,
              child: TextField(
                textAlign: TextAlign.center,
                keyboardType: TextInputType.number,
                maxLength: 6,
                onChanged: (value) {
                  this.smsOtp = value;
                },
              ),
            ),
            actions: [
              FlatButton(
                onPressed: () async {
                  (context);
                  try {
                    PhoneAuthCredential phoneAuthCredential =
                      PhoneAuthProvider.credential(
                        verificationId: verificationId,
                        smsCode: smsOtp,
  
                      );
  
                    final User ? user = (await _auth.signInWithCredential(phoneAuthCredential)).user;
  
                    //create user data in fireStore after successful login
                    _createUser(id: user!.uid, number: user.phoneNumber ? ? "");
                    //navigate to homepage after login
                    if (user != null) {
                      Navigator.of(context).pop();
  
                      //dont want to come back to welcome screen after login
                      Navigator.of(context).pushReplacement(MaterialPageRoute(
                        builder: (context) =&gt; HomeScreen(),
                      ));
                    } else {
                      print('Login Failed');
                    }
  
                  } catch (e) {
                    this.error = 'Invalid Code';
                    print(e.toString());
                    notifyListeners();
                    Navigator.of(context).pop();
                  }
                },
                child: Text('DONE', style: TextStyle(color: Theme.of(context).primaryColor), ),
              ),
            ],
          );
        });
    }
  
    void _createUser({
      required String id,
      required String number
    }) {
      _userServices.createUserData({
        'id': id,
        'number': number,
      });
    }
  }</code></pre>
  </div>
  </div>
  </p>