requestSendCode method Null safety

  1. @override
dynamic requestSendCode()
override

Implementation

@override
requestSendCode() async {
  update(state: PhoneVerificationState.requestingSendCode);
  await FirebaseAuth.instance.verifyPhoneNumber(
    phoneNumber: phoneNumber.phoneNumber!,
    timeout: Duration(seconds: 0),
    forceResendingToken: _phoneVerification.resendToken,
    verificationCompleted: (PhoneAuthCredential credential) {
      dev.log('verificationCompleted',
          name: 'FirebaseAuth.instance.verifyPhoneNumber()');
      update(state: PhoneVerificationState.verifiedCode);
    },
    verificationFailed: (FirebaseAuthException e) {
      dev.log('verificationFailed',
          name: 'FirebaseAuth.instance.verifyPhoneNumber()');
      _handleError(e);
    },
    codeSent: (String verificationId, int? resendToken) {
      dev.log('codeSent', name: 'FirebaseAuth.instance.verifyPhoneNumber()');
      _phoneVerification.verificationId = verificationId;
      _phoneVerification.resendToken = resendToken;
      update(state: PhoneVerificationState.inputCode);
      if (Platform.isAndroid) {
        update(state: PhoneVerificationState.waitingCodeReceive);
      }
    },
    codeAutoRetrievalTimeout: (String verificationId) {
      dev.log('codeAutoRetrievalTimeout',
          name: 'FirebaseAuth.instance.verifyPhoneNumber()');
      _phoneVerification.verificationId = verificationId;
      if (Platform.isAndroid) {
        update(state: PhoneVerificationState.timeoutWaitingCodeReceive);
      }
    },
  );
}