staleTime property

Duration get staleTime

How long cached data is considered fresh before a background revalidation is triggered.

  • Duration.zero (default): data is immediately stale; always revalidated on the next access.
  • null-equivalent large value: effectively never stale.

The SWR (stale-while-revalidate) pattern means stale data is returned immediately while the fetch runs in the background.

Implementation

Duration get staleTime => _staleTime ?? Duration.zero;