SwrMutate<T> typedef

SwrMutate<T> = Future<void> Function({T? data, List<Object> invalidate, T updater(T?)?})

Bound mutate function returned by useSwr, scoped to the hook's own key: mutate(data: newValue) / mutate(updater: (prev) => next) writes directly to the cache (bypassing dedup — a direct write isn't a fetch), then revalidates; mutate() with neither just revalidates.

invalidate: [...] additionally cascades a revalidation onto other keys (PRODUCT_DETAILS.md §7). For each key: if a controller is currently registered for it and it has an active cache subscriber (some useSwr is mounted on it), it's revalidated using its own last-used fetcher — no data is written for these keys, only the caller's own key. A key with no registered controller or no mounted subscriber is a safe no-op: nothing is created or marked stale for it, since there would be nothing to notify anyway.

Implementation

typedef SwrMutate<T> =
    Future<void> Function({
      T? data,
      T Function(T?)? updater,
      List<Object> invalidate,
    });