Skip to main content

Examples

Each page below is one screen of the showcase app: what it demonstrates, a live demo that runs in your browser against an in-memory backend (nothing is downloaded until you press Run), what to try in it, and the source of the screen, taken from the compiled file. Every screen draws its cache entries' state as it changes, so you can watch what the library does, not just what the widget shows.

A demo is a Flutter web app in a frame, and it behaves like one: clicking outside it and back in is a window focus change, so a stale query refetches on the way back in, as it would in your app. A fetches= count a page promises can therefore be one higher if you clicked away in between.

Whole apps​

  • Task manager: one ordinary small app, a to-do list against a slow backend that fails on cue. Where the showcase lets you look a feature up, this shows how six of them compose: a list two widgets share, a detail screen, optimistic writes with rollback, and a reminder that is accepted before it is confirmed.
  • One-file tour: the package's own example, a provider, one query read two ways and a mutation, in a single file with no server.

Basics​

  • SimpleOne query, its states, and a refetch.
  • BasicA list, a detail, and what the cache already knows.
  • Four call stylesThe same query through context, builder, mixin and controller.

Queries​

Paging​

Mutations​

Cache​

Network​

  • Auto refetchingPolling on an interval, in the foreground or not.
  • RetryRetry policies and delays, and what the result shows meanwhile.
  • CancellationA query cancelled is a request aborted.
  • OfflineNetwork modes, paused mutations, and coming back online.
  • Focus refetchWhat happens when the app comes back to the foreground.

Advanced​

  • Filtering rebuildsbuildWhen on the eight keyless reads, each beside its unfiltered twin.
  • Global callbacksCache-level callbacks, and meta on its way through.
  • DiagnosticsWhat the library throws, and when: the wrong type, the missing function.

Running them yourself​

Both apps live in the repository with a small backend each. The showcase:

cd examples/showcase/server && npm install && npm run dev
cd examples/showcase && flutter run -d chrome

The task manager runs on the web and iOS:

cd examples/task_manager/server && npm install && npm run dev
cd examples/task_manager && flutter run -d chrome

Either app also runs with no server, as the live demos do: flutter run -d chrome --dart-define=QK_BACKEND=inmemory.

How all of them are tested, from widget tests to a browser suite against the real backend, is on how the examples are built.