signUpWithPhone method

Future<GotrueSessionResponse> signUpWithPhone(
  1. String phone,
  2. String password, {
  3. AuthOptions? options,
  4. Map<String, dynamic>? userMetadata,
})

Signs up a new user using their phone number and a password.

phone is the user's phone number WITH international prefix

password is the password of the user

userMetadata sets User.userMetadata without an extra call to update

Implementation

Future<GotrueSessionResponse> signUpWithPhone(
  String phone,
  String password, {
  AuthOptions? options,
  Map<String, dynamic>? userMetadata,
}) async {
  _removeSession();

  final response =
      await api.signUpWithPhone(phone, password, userMetadata: userMetadata);
  if (response.error != null) return response;

  if (response.data?.user?.phoneConfirmedAt != null) {
    _saveSession(response.data!);
    _notifyAllSubscribers(AuthChangeEvent.signedIn);
  }

  return response;
}