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
- Appwrite (Dart SDK) (for package_info_pl...
Hi team! Many Flutter plugins now need package_info_plus 10.x and device_info_plus 13.x, but appwrite 25.4.0 still constrains package_info_plus: >=8.0.2 <10.0...
- Images/Videos in storage appearing broke...
I am running into a storage issue after upgrading my self-hosted Appwrite instance , all of my previously uploaded images and videos are now showing as broken i...
- executeFunction intermittently throws Fo...
Environment: Flutter app using the Appwrite Flutter SDK, calling executeFunction for [describe endpoint, e.g. live-stream-related function]. *Description*: Int...