Skip to main content
Cached Query Logo

Cached Query

Create fast user interfaces with Cached Query and Flutter

Use in dart:


Query<User> userQuery(String userId) {
return Query<User>(
key: 'user_data?id=$userId',
queryFn: () => fetchUserData(userId),
);
}

userQuery("12").stream.listen((state){});

To use in Flutter UI:


class UserView extends StatelessWidget {
const UserView({super.key});


Widget build(BuildContext context) {
return QueryBuilder(
query: userQuery("12"),
builder: (context, state) {
return switch (state) {
QueryLoading<User>() ||
QueryInitial<User>() =>
const CircularProgressIndicator(),
QueryError<User>(:final error) => Text('Error: $error'),
QuerySuccess<User>(:final data) => Text('User: ${data.name}'),
};
},
);
}
}

Easy to Use

Cached query has been designed to be minimal and easy to integrate into existing projects.

server_cluster

Works with Bloc

Complements any architecture you may already be using.

Improve UX

Easily improve the user experience of any flutter app by keeping data local, reducing the reliance of loading spinners