Handle error backend query

Actions & Logic

Hello,

I have a page on my app and i pass a parameter to this page (refDoc: it's the reference of a document)
And at the root of the page i do a backend query document from reference and i give this refDoc to it.

It works fine BUT sometime the refDoc will be empty. And I if I pass an empty refDoc now I have this error.

But it's fine because if this refDoc is null i will not use the output of this query. So i would like just either don't run the query IF the refDoc is null. Either just ignor the error.

It's like this, I cannot ( and don't want) do a conditional builder because in the if true and if false will be the same element inside, it's just the output of the query i pass it in a small function and if it's nul or empty of whatever that just take an other value so it's fine if that return null.
I guess the best practice it's just to just not run the backend query but i don't know how to pass just the query in a if.

What have you tried so far?

I tried to remove this backend query and add an action "On Load Page" and do a "read document firebase" (i guess the backend query document from reference do the same action) which is in a IF. BUT the issue with that is i'm loosing the realtime update... because the action just read one time the document... and i wanted to use the backendquery specialy for that...

I'm thinking to create a random document in firebase and if refDoc is empty i take this random document, but i don't like this, i tried but i don't even know how to create in FF a constant reference doc...

So if you have any idea ๐Ÿ˜€

Thanks

Did you check FlutterFlow's Documentation for this topic?
Yes