Back

Flutter/Dart Account.get() throwing exception

  • 0
  • Users
  • Flutter
  • Databases
  • Accounts
ZachHandley
25 Jul, 2023, 19:29

As stated above I'm having an issue in Flutter/Riverpod where account.get() throws an exception if the user is not logged in, which means my user auth state is either in Error or logged in, I would love a way to query for that info without the possibility of exception but

I have this provider for account.get() which returns an AppwriteException if they're not logged in

TypeScript
@Riverpod(keepAlive: true)
Future<User> authState(AuthStateRef ref) async {
    return await ref.watch(appwriteAccountProvider).get();
}

I can't do anything about the exception I thought it would return an AsyncValue<User> so it would be an AsyncError How do I properly do this? maybe get rid of the await?

TL;DR
Title: Flutter/Dart Account.get() Exception Handling Messages: - User is having an issue with `account.get()` throwing an exception if the user is not logged in. - They are looking for a way to query user authentication state without the possibility of exceptions. - They have a provider for `account.get()` that currently returns an `AppwriteException` if the user is not logged in. - They are unsure about how to handle the exception properly and are considering removing the `await` keyword. Solution: - Use a try-catch block to handle the exception when calling `account.get()` and handle it accordingly. - Alternatively,
Drake
25 Jul, 2023, 19:33

Didn't you have another thread on this topic?

ZachHandley
25 Jul, 2023, 19:45

Yeah sort of? I wanted to make a new thread because the title of the last one was a question and this one I meant to make more of a solution, I can delete this one though and edit the title if that's preferable, sorry about that

Drake
25 Jul, 2023, 19:51

Ya probably best to continue the conversation in your existing post

Drake
25 Jul, 2023, 19:52

Ill delete this

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more