Skip to content

ishafiul/fasq

Repository files navigation

Fasq (Flutter Async State Query)

The caching-first async state management library for Flutter.

Pub Version License: MIT Build Status

Fasq handles async state management, server-state caching, and synchronization for Flutter applications. It is designed to be:

  • 🚀 Performant: Intelligent caching, background refetching, and request deduplication.
  • 🛠️ Flexible: Works with any state management (Bloc, Riverpod, Hooks, or standalone).
  • 🔒 Secure: Built-in encryption support for sensitive data.
  • 📱 Production Ready: Robust error recovery, offline support, and 100% type safety.

Inspired by TanStack Query and SWR.

📦 Packages

This monorepo manages the following packages:

Package Version Description
fasq Pub The core caching, query, and mutation engine.
fasq_bloc Pub Integration with flutter_bloc.
fasq_hooks Pub React-style hooks (useQuery, useMutation).
fasq_riverpod Pub Providers for flutter_riverpod.
fasq_security Pub Encryption and secure storage plugin.
fasq_serializer_generator Pub Codegen for typed query keys.

📚 Documentation

Detailed documentation is available at fasq.shafi.dev.

🚀 Quick Start

1. Install

Add fasq to your pubspec.yaml (or your preferred adapter):

dependencies:
  fasq: ^0.3.7
  # Optional adapters:
  # fasq_bloc: ...
  # fasq_riverpod: ...
  # fasq_hooks: ...

2. Configure Client

Available anywhere in your app via QueryClientProvider or specific adapter providers.

void main() {
  runApp(
    QueryClientProvider(
      client: QueryClient(),
      child: MyApp(),
    ),
  );
}

3. Fetch Data

QueryBuilder<List<Todo>>(
  queryKey: 'todos',
  queryFn: () => api.fetchTodos(),
  builder: (context, state) {
    if (state.isLoading) return CircularProgressIndicator();
    if (state.hasError) return Text('Error: ${state.error}');
    
    return ListView.builder(
      itemCount: state.data!.length,
      itemBuilder: (context, index) => Text(state.data![index].title),
    );
  },
)

🤝 Contributing

We welcome contributions! Please see the CONTRIBUTING.md file for details on how to get started.

Setup for Development

This project relies on Melos to manage the monorepo.

  1. Clone the repo:
    git clone https://github.com/ishafiul/fasq.git && cd fasq
  2. Install Melos:
    dart pub global activate melos
  3. Bootstrap:
    melos bootstrap

Running Tests

Run unit and widget tests across all packages:

melos run test:all

📄 License

Fasq is released under the MIT License. See LICENSE for details.

🙏 Acknowledgements

  • TanStack Query (React Query): The primary inspiration for the architecture and API design.
  • SWR: For the "stale-while-revalidate" philosophy.

Built with ❤️ by Shafiul Islam.

Releases

No releases published

Packages

No packages published