Home > Back-end >  How do I get loading state/spinner with flutter riverpod statenotifier, ref watch and asyncvalue?
How do I get loading state/spinner with flutter riverpod statenotifier, ref watch and asyncvalue?

Time:09-03

I have the below example which does refresh the data but does not give a spinner as expected. I tried using ref.listen to switch to async loading, i tried await in front of the call even though it didn't make sense.

I tried ref.refresh, ref.invalidate... Expected behaviour: Open app, see spinner, tap button, see spinner again before text changes. Actual behaviour: Open app, see spinner, tap button, text changes and no spinner shows. also see enter image description here

CodePudding user response:

I think you're seeing this breaking changed behavior:

Breaking After a provider has emitted an AsyncValue.data or AsyncValue.error, that provider will no longer emit an AsyncValue.loading. Instead, it will re-emit the latest value, but with the property AsyncValue.isRefreshing to true.

So the behavior you describe is by design.

  • Related