0

I am trying to add raw_user_metadata on the auth.users table when a new user creates an account. However, I'm unable to find the documentation for how to do so in Flutter. The documentation exists for the Javascript client library so it seems to be possible, but it isn't documented for Flutter.

See the "sign up with additional user metatdata" javascript documentation here: https://supabase.com/docs/reference/javascript/auth-signup

In javascript, this is how you add raw_user_metadata:


const { data, error } = await supabase.auth.signUp(
  {
    email: '[email protected]',
    password: 'example-password',
    options: {
      data: {
        first_name: 'John',
        age: 27,
      }
    }
  }
)

How can I accomplish the same thing in Flutter?

3 Answers 3

0

You can do it like this:

final AuthResponse res = await supabase.auth.signUp(
  email: '[email protected]',
  password: 'example-password',
  data: {'username': 'my_user_name'},
);
Sign up to request clarification or add additional context in comments.

Comments

0

I found this in the Supabase Flutter related docs itself:

 final AuthResponse res = await supabase.auth.signUp(
    email: '[email protected]',
    password: 'example-password',
 );
 final Session? session = res.session;
 final User? user = res.user;

Comments

0

data param on signup() is a Map<String, dynamic>?. So you can try this:

Future<AuthResponse?> signup(
  String fname, 
  String lname, 
  String gender, 
  String bdate, 
  String email, 
  String password,
) async {

  final Map<String, dynamic> data = {
    'first_name': fname,
    'last_name': lname,
    'gender': gender,
    'birthdate': bdate
  };

  return supabase.auth.signUp(
    password: password,
    email: email,
    data: data,
  );
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.