signUp method

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

Creates a new user.

userMetadata sets User.userMetadata without an extra call to update

Implementation

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

  final response = await api.signUpWithEmail(
    email,
    password,
    options: options,
    userMetadata: userMetadata,
  );
  if (response.error != null) return response;

  // ignore: deprecated_member_use_from_same_package
  if (response.data?.user?.confirmedAt != null ||
      response.data?.user?.emailConfirmedAt != null) {
    _saveSession(response.data!);
    _notifyAllSubscribers(AuthChangeEvent.signedIn);
  }

  return response;
}