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
- π Realtime Flutter SDK Crash β Realtime...
**Summary** When using Appwrite Cloud with the Flutter SDK (latest appwrite release: 21.4.0), Realtime crashes with: ```Unhandled async error: type '_Map<String...
- Realtime Connection Error After Updating...
I get the following error message now when the realtime subscription picks up a new message. There's more to the error but it makes the discord message too long...
- I am currently seeking opportunities as ...
Hey! π I'm a Shopify guy. Been building stores for 8+ years. Still haven't lost my mind. Barely. I make stores that don't suck fast, smooth, and actually built...