Hello again, sorry for bother you guys.
I'm getting this exception when trying to login. I put bad credentials on purpose.
I just want to know how to catch this exceptions, I have added already onError, and make it returns null. But it throws another exception.
This is my code:
Future? login({required String email, required String password}) {
try {
return account
.createEmailSession(email: email, password: password)
.then((value) => value)
.onError((error) => null); // <-- null is marked as error, Want to know with what can I replace that
} catch (e) {
print(e);
return null;
}
}
Thanks for your help
As the error says, you must return a value of the future's type (in this case, session) and can't return null.
Btw, i highly suggest you avoid trying to mix and match then/onError with try/catch. When possible, only use async/await/try/catch as it makes code much easier to read
You point me in the right direction, using async await turns into more readable code and easy debug.
Thank you so much @Steven!
You are awesome
[SOLVED] How to catch on promise errors?
Recommended threads
- Apple OAuth Scopes
Hi Hi, I've configured sign in with apple and this is the response i'm getting from apple once i've signed in. I cant find anywhere I set scopes. I remember se...
- Sign In With Apple OAuth Help
Hi All! I've got a flutter & appwrite app which Im trying to use sign in with apple for. I already have sign in with google working and the function is the sam...
- [SOLVED] OAuth With Google & Flutter
Hi all, I'm trying to sign in with google and it all goes swimmingly until the call back. I get a new user created on the appwrite dashboard however the flutte...