There is a scenario in which I need to invalidate/refresh my AsyncNotifier
to start fresh, but when I invalidate it I face 2 issues:
- I have a variable inside my
AsyncNotifier
class that after invalidating that provider still holds on to the data that it had before invalidation, then how should I invalidate a provider to make it refresh everything including variables locally in that class? - It still returns
AsyncData
but changes theisLoading
intotrue
, but I thought it should set datanull
and then start thebuild
function, am I wrong? I'd appreciate it a lot if you could help me!
Calling ref.invalidate will reset the visible state to AsyncLoading, but the AsyncValue holds "prior" status in some cases for seamless transitions. If you use the default .when, it will go seamlessly from the old value to the new value once the new value is built. If you want to go back to loading state in between, either add the appropriate flag to .when, or use an explicit pattern match on AsyncLoading vs AsyncData.