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
- Weird permission failure
when creating an account I use following methods: ``` Future<void> register(String email, String password, String username) async { final user = await accoun...
- Flutter Android oAuth is no more working
I currently don't get the oAuth login to work in flutter android. it works on ios and on web. but when try to use it on Android, i get to the point where the ca...
- I'm experiencing a critical bug on Appwr...
Hey <@870607367597850624> team / support š I'm experiencing a critical bug on Appwrite Cloud that's blocking my production Flutter app. I've already filed GitH...