flutter_query 0.6.0 copy "flutter_query: ^0.6.0" to clipboard
flutter_query: ^0.6.0 copied to clipboard

Fetch, cache, and sync server data with automatic state management and background updates, inspired by TanStack Query.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:flutter_query/flutter_query.dart';

void main() {
  runApp(
    QueryClientProvider(
      create: (context) => QueryClient(),
      child: MaterialApp(home: Example()),
    ),
  );
}

class Example extends HookWidget {
  @override
  Widget build(BuildContext context) {
    final result = useQuery<String, Exception>(
      const ['greeting'],
      (context) async {
        // Simulate network delay
        await Future.delayed(const Duration(seconds: 3));
        return 'Hello, Flutter Query!';
      },
    );

    return Scaffold(
      appBar: AppBar(title: const Text('Flutter Query Example')),
      body: Center(
        child: switch (result) {
          QueryResult(:final data?) => Text(data),
          QueryResult(isPending: true) => const Text('Loading...'),
          QueryResult(:final error) => Text('Error: $error'),
        },
      ),
    );
  }
}
34
likes
160
points
467
downloads

Publisher

verified publisherflutterquery.com

Weekly Downloads

Fetch, cache, and sync server data with automatic state management and background updates, inspired by TanStack Query.

Repository (GitHub)
View/report issues

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

clock, collection, flutter, flutter_hooks, meta

More

Packages that depend on flutter_query