signInWithPhoneNumber static method

Future<User?> signInWithPhoneNumber(
  1. BuildContext context, {
  2. String? phoneNumber,
  3. dynamic onError(
    1. String
    )?,
  4. Function? onInvalidVerificationCode,
  5. dynamic onSignInSuccessful(
    1. User?
    )?,
  6. bool closeVerificationPopupAfterSubmit = false,
})

Initiates a PhoneNumber SignIn, brings up an OTPVerificationModal and then the AuthManager changes the screen to the destinationFragment

Please enable Phone Authentication in your Firebase Authentication Console for this to work

Please ensure you have added your SHA-1 and SHA-256 Keys to Firebase

If you want to avoid ReCaptcha Redirect verification, Go to Google Cloud Console, Open your firebase project, search Android Device Verification and enable it

The Phone Number must be in the format: +<country code><phone number>

context is necessary

phoneNumber is the phoneNumber used to login

onError is a callback to handle any errors in this process

onInvalidVerificationCode is a callback to handle the situation where the OTP is incorrect

onSignInSuccessful a Callback to perform any action after a successful SignIn

closeVerificationPopupAfterSubmit a boolean which when true, closes the OTP Verification Dialog after an attempt and if false leaves it open, basically if the User Wants to Retry

Implementation

static Future<User?> signInWithPhoneNumber(
  BuildContext context, {
  String? phoneNumber,
  Function(String)? onError,
  Function? onInvalidVerificationCode,
  Function(User?)? onSignInSuccessful,
  bool closeVerificationPopupAfterSubmit = false,
}) async {
  final provider = Provider.of<FireAuthProvider>(context, listen: false);
  return await provider.signInWithPhoneNumber(
    context: context,
    phoneNumber: phoneNumber,
    onError: onError,
    onInvalidVerificationCode: onInvalidVerificationCode,
    onSignInSuccessful: onSignInSuccessful,
    closeVerificationPopupAfterSubmit: closeVerificationPopupAfterSubmit,
  );
}