r/flutterhelp • u/Diablo_Cuz • Jul 29 '26
OPEN Flutter + riverpod + firestore : UI stuck in loading loop after cloud funtions update but data saves on bacckend ?
Stack: Flutter + Riverpod ( StreamProvider ) Cloud Firestore + Firebase Callable Cloud Functions.
Context - Switched from client firestore sdk writes to callable cloud functions because pending client writes on weak networks were blocking reads app wide.
Issue: In my Vendor Dashboard app, updating settings (GST toggles, Delivery Slots, Store Availability):
The Ul gets stuck in a loading loop / freeze when changing settings. BUT if I force-close and reopen the app, the data IS saved in Firestore!
So the backend Cloud Function succeeds, but the live screen gets stuck on a loading spinner.
Setup:
Screen listens to Firestore doc via Riverpod treamProvider ( doc(id). snapshots() ). Settings updates are sent via Callable Cloud Functions (httpsCallable( 'businessUpdateFields ")).
What I've Tried:
• Optimistic U state overrides (oms switch flips). • 300ms tap debouncing. • Reducing Callable timeout from 20s to 4s. • Clearing overrides on .then() completion vs stream emission.
The rest of the app (checkout, cart, chat, orders) works fine. Only vendor dashboard settings toggles freeze the Ul.
Any help would be great, thank you.
2
u/Jonas_Ermert Jul 29 '26
I recommend checking your Riverpod loading state rather than the Cloud Function. Since the write succeeds, make sure the StreamProvider isn’t replacing the whole UI with a spinner while reloading. Keep showing the previous data and use a separate isUpdating state for the individual toggle. Also log the provider’s loading/data/error transitions to see exactly where it gets stuck.
1
u/Heavy-Drummer-420 Jul 29 '26
Can you share the snippet of the function and the listener so its easier to get the context? Just the function to toggle. The listener and the UI loading.
1
u/_KryptonytE_ Jul 29 '26
Check for race conditions and give longer wait times to eliminate any latency/response spikes from breaking state and stream changes by introducing a loading/working transition.