Hi I would like for the addUserToFirestore() function to trigger after the code above has done being executed
Future<void> registerAccount(
String email,
String displayName,
String password,
void Function(FirebaseAuthException e) errorCallback) async {
try {
var credential = await FirebaseAuth.instance
.createUserWithEmailAndPassword(email: email, password: password);
await credential.user!.updateDisplayName(displayName);
addUserToFirestore();
} on FirebaseAuthException catch (e) {
errorCallback(e);
}
}
try and change your code to:
await credential.user!.updateDisplayName(displayName)
.then((_) => addUserToFirestore());
so that addUserToFirestore()
will only fire after updateDisplayName()
is complete
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.