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

An async state management package that simplifies data fetching, caching, and updates.

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() {
  final queryClient = QueryClient();

  runApp(
    QueryClientProvider(
      client: queryClient,
      child: MaterialApp(home: Example()),
    ),
  );

  queryClient.dispose();
}

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'),
        },
      ),
    );
  }
}
28
likes
150
points
89
downloads

Publisher

verified publisherflutterquery.com

Weekly Downloads

An async state management package that simplifies data fetching, caching, and updates.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

async, clock, collection, flutter, flutter_hooks, meta

More

Packages that depend on flutter_query