verifyPhoneNumber method Null safety

Future<void> verifyPhoneNumber(
  1. {required String phoneNumber,
  2. required PhoneVerificationCompleted verificationCompleted,
  3. required PhoneVerificationFailed verificationFailed,
  4. required PhoneCodeSent codeSent,
  5. required PhoneCodeAutoRetrievalTimeout codeAutoRetrievalTimeout,
  6. @visibleForTesting String? autoRetrievedSmsCodeForTesting,
  7. Duration timeout = const Duration(seconds: 30),
  8. int? forceResendingToken}
)

Starts a phone number verification process for the given phone number.

This method is used to verify that the user-provided phone number belongs to the user. Firebase sends a code via SMS message to the phone number, where you must then prompt the user to enter the code. The code can be combined with the verification ID to create a PhoneAuthProvider.credential which you can then use to sign the user in, or link with their account ( see signInWithCredential or linkWithCredential).

On some Android devices, auto-verification can be handled by the device and a PhoneAuthCredential will be automatically provided.

No duplicated SMS will be sent out unless a forceResendingToken is provided.

phoneNumber The phone number for the account the user is signing up for or signing into. Make sure to pass in a phone number with country code prefixed with plus sign ('+').

timeout The maximum amount of time you are willing to wait for SMS auto-retrieval to be completed by the library. Maximum allowed value is 2 minutes.

forceResendingToken The forceResendingToken obtained from codeSent callback to force re-sending another verification SMS before the auto-retrieval timeout.

verificationCompleted Triggered when an SMS is auto-retrieved or the phone number has been instantly verified. The callback will receive an PhoneAuthCredential that can be passed to signInWithCredential or linkWithCredential.

verificationFailed Triggered when an error occurred during phone number verification. A FirebaseAuthException is provided when this is triggered.

codeSent Triggered when an SMS has been sent to the users phone, and will include a verificationId and forceResendingToken.

codeAutoRetrievalTimeout Triggered when SMS auto-retrieval times out and provide a verificationId.

Implementation

Future<void> verifyPhoneNumber({
  required String phoneNumber,
  required PhoneVerificationCompleted verificationCompleted,
  required PhoneVerificationFailed verificationFailed,
  required PhoneCodeSent codeSent,
  required PhoneCodeAutoRetrievalTimeout codeAutoRetrievalTimeout,
  @visibleForTesting String? autoRetrievedSmsCodeForTesting,
  Duration timeout = const Duration(seconds: 30),
  int? forceResendingToken,
}) {
  return _delegate.verifyPhoneNumber(
    phoneNumber: phoneNumber,
    timeout: timeout,
    forceResendingToken: forceResendingToken,
    verificationCompleted: verificationCompleted,
    verificationFailed: verificationFailed,
    codeSent: codeSent,
    codeAutoRetrievalTimeout: codeAutoRetrievalTimeout,
    // ignore: invalid_use_of_visible_for_testing_member
    autoRetrievedSmsCodeForTesting: autoRetrievedSmsCodeForTesting,
  );
}