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
- 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...