Skip to content
The Fuery logo, three rounded tiles forming an FThe Fuery logo, three rounded tiles forming an F

Fuery

Fetch, cache, and keep server data fresh in Flutter.
// A Query<List<Todo>>, with no type arguments.
final todos = Query(
queryKey: ['todos'],
queryFn: (_) => api.getTodos(),
);
QueryBuilder(
query: todos,
builder: (context, state) => switch (state.data) {
final data? => TodoList(data), // a List<Todo>
null => const CircularProgressIndicator(),
},
)

Server state in Flutter explains why server data needs a cache. Mutations create, update, and delete it, with optimistic updates.

Built the Flutter way

A screen that shows a query stays a StatelessWidget. You define queries outside build, and widgets render them the way StreamBuilder renders a stream: builders for UI, listeners for side effects. Adopt Fuery one screen at a time, with nothing to replace. For hooks, fuery_hooks renders the same queries with useQuery, in a package of its own.

Nothing beyond Dart and Flutter

No code generation, no native code, and no platform setup. The core is pure Dart and depends only on the Dart team’s clock, collection, and meta. Widgets, cubits, blocs, services, CLIs, and servers use the same query object.

Cached and fresh

Every widget that uses a key shares one cache entry and one request. Stale data stays on screen while Fuery refetches it in the background. A refetch that returns equal items, by ==, keeps the previous objects, so those list rows don’t rebuild.

Types from your functions

Queries, mutations, and infinite queries take their types from their functions. Widgets, results, and callbacks carry those types without type arguments. Two cases name the type: a read or write by key alone, as in getQueryData<List<Todo>>(['todos']), and an infinite query whose first page param is null.

Built for real networks

Queries on screen retry a failed fetch 3 times with backoff and refetch when the app resumes. With a connectivity source, they pause while the device is offline and refetch when it reconnects. Fuery cancels a query function that reads context.signal once nothing uses it, and doesn’t report the cancellation as an error. A query can poll until a condition holds, or fold a stream into the cache.

Persisted and inspectable

Queries you persist survive app restarts, with any key-value storage. The devtools show the cache inside the running app, on a device.

Tested. Every package has 100% line coverage, and CI fails when a line loses it. The tests run on the oldest supported Flutter (3.27) and on the latest. The core’s tests run under fake time. A regression suite keeps fixed edge cases fixed. Fuery cancels every timer on its destroy path and reads time from package:clock, so your own fake_async and widget tests don’t leak timers. See Testing.

Fuery’s caching and refetching model is inspired by TanStack Query. Coming from TanStack Query gives the Fuery name for each of its concepts.