
wdym?

snapshot is of type object

snapshot is basically
AsyncSnapshot<YOUR_TYPE> snapshot
no snapshot.data
would return the data of the type you have passed
and snapshot.error
would give back the exception it had during calling of the function

now the error could be of any type. In your case , it should be object or dynamic

where/how would i write checks for that there is no property error in my snapshot object

nvm figured out

@Maniac_Fighter after writing checks inside the builder the exception is still being thrown

problem comes before the builder can read the checks

can you share your futurebuilder code ??

where snapshot is the getfie(index) passed down from widget

it doesnt even matter the exception is thrown before the code is called

so it should show in the stackTrace where the exception is being thrown right?

yeah shown under debug vars too



Also let's try to refactor this as well,
getFile must be Future<Uint8List>
Also , it needs async
await
Avoid using then, if you want the result, try storing it in a variable then print it
Now when you get the error, or when it reaches the catch block, its necessary, to either return a type of Uint8List
or throw an exception
so instead of return forceError, use throw
or rethrow
Now your future builder would be able to catch it

in the stack trace, could you see the who is calling that function??

already tried async await until i realised futurebuilder expects of type Future<Object?>? and not Future<Uint8List>

FutureBuilder accepts any type you just need to define it explicitly

FutureBuilder<T>

if not types given, then it considers an object automatically

ill see what i can do thank you for your patience

i fixed it, for some reason it wouldnt use throw and rethrow so i made the types nullable and returned null at the cost of not being able to use the error property

If it works don't touch it

[SOLVED] Catching errors with futurebuilders during api calls
Recommended threads
- user_unauthorized
"I tried to use the CLI, but it returns user_unauthorized. Iâm already logged in with my Appwrite account. Could there be an issue on the cloud side?" `erdene...
- OAuth2 with IPhone When users enables "H...
I am using Appwrite OAuth2 to authenticate users in my app (Flutter) Normally, I am using the user's email for the authentication, when he first registers , and...
- Still showing this after complete my pay...
This project is in readonly mode. Please contact the organization admin for details.
