Skip to Content
DocumentationIntroduction

Introduction

Fasq (Flutter Async State Query) is a powerful, developer-friendly state management solution for asynchronous data in Flutter. It handles fetching, caching, synchronizing, and updating server state in your application with zero boilerplate.

Why Fasq?

Managing server state in Flutter can be challenging. You often need to:

  • Show loading spinners while fetching data
  • Handle errors gracefully
  • Cache data to save bandwidth and improve performance
  • Update UI instantly when data changes
  • Refresh data in the background

Fasq handles all of this for you with a simple, widget-based API that feels native to Flutter.

Key Features

  • Automatic Caching: Data is cached automatically. Navigation back to a screen shows data instantly.
  • Background Refetching: Stale data is shown immediately while fresh data is fetched in the background.
  • Request Deduplication: Multiple widgets asking for the same data? Only one network request is made.
  • Window Focus Refetching: Automatically refetch data when the app comes back to the foreground.
  • Optimisitc Updates: Update your UI immediately when performing mutations, then sync with the server.
  • Infinite Queries: Built-in support for infinite scrolling lists.
  • Offline Support: Queue mutations when offline and sync when online.

Installation

Install the core package using the Flutter CLI:

flutter pub add fasq

[!TIP] Using a state management library? Check out our optimized Adapters.

Quick Example

Fasq is designed to work out of the box with QueryBuilder:

import 'package:flutter/material.dart'; import 'package:fasq/fasq.dart'; class TodoList extends StatelessWidget { @override Widget build(BuildContext context) { return QueryBuilder<List<Todo>>( queryKey: 'todos'.toQueryKey(), queryFn: () => api.fetchTodos(), builder: (context, state) { if (state.isLoading) { return const Center(child: CircularProgressIndicator()); } if (state.hasError) { return Center(child: Text('Error: ${state.error}')); } if (state.hasData) { return ListView.builder( itemCount: state.data!.length, itemBuilder: (context, index) { final todo = state.data![index]; return ListTile(title: Text(todo.title)); }, ); } return const SizedBox(); }, ); } }

Ecosystem

Fasq works great on its own, but also integrates with your favorite state management solutions via adapters:

Next Steps

Last updated on