I am calling createUserWithEmailAndPassword
. When succesful, then
callback should be running. However, it is not. whenComplete
callback is running as expected. There is no error, so onError
is not running, as expected. It is a problem because I need the parameter in the then
.
Why is it doing this?
I am using Flutter Web
FirebaseAuth auth = FirebaseAuth.instance;
await auth
.createUserWithEmailAndPassword(
email: emailController.text,
password: passwordController.text)
.then((value) => () async {
print("user created");
return value;
})
.whenComplete(() {
print("when callback");
}).onError((error, stackTrace) {
print("error: $error");
return Future.value();
});
3
Answers
I got it working.
Please test on it to make sure process – the theory – it go to whenComplete before go to then please – it is process.
try this :