-2
I can expect an asynchronous terminal function to continue the code?
I have an asynchronous function with a Try/catch and want to catch the bug to treat.
Login(BuildContext context) async {
try {
FirebaseUser _login = (await FirebaseAuth.instance
.signInWithEmailAndPassword(email: email, password: pass))
.user;
if (_login != null) {
userid = _user.uid;
Modular.to.pushNamed('/inicial');
}
} catch (e) {
msge = e.code;
}
}
When I call the function and try to get the msge it returns null, I did some tests and from what I understand it returns null because it has not yet finished.
Is there any way to take this data?
An asynchronous function always returns an object of type
Future. The operatorawaitawaits resolution of thatFutureand takes the result of it. If you are receivingnull, thennullis the result ofFuture, you are waiting correctly, the result is that it is empty even.– Andre
But this function I use to check the right login? When the email is wrong firebase returns 'EMAIL_INVALID' which is e.code, but what should be happening is, when it arrives at msge = e.code o e.code is null because await has not returned yet. Would that be?
– Fernando Foster