Skip to content

Instantly share code, notes, and snippets.

@sbis04
Created September 9, 2020 11:38
Show Gist options
  • Save sbis04/6ca36ad3523228bed92930e3494b22fe to your computer and use it in GitHub Desktop.
Save sbis04/6ca36ad3523228bed92930e3494b22fe to your computer and use it in GitHub Desktop.
Future<String> registerWithEmailPassword(String email, String password) async {
// Initialize Firebase
await Firebase.initializeApp();
final UserCredential userCredential = await _auth.createUserWithEmailAndPassword(
email: email,
password: password,
);
final User user = userCredential.user;
if (user != null) {
// checking if uid or email is null
assert(user.uid != null);
assert(user.email != null);
uid = user.uid;
userEmail = user.email;
assert(!user.isAnonymous);
assert(await user.getIdToken() != null);
return 'Successfully registered, User UID: ${user.uid}';
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment