utopia_hooks_query 0.7.0+1 copy "utopia_hooks_query: ^0.7.0+1" to clipboard
utopia_hooks_query: ^0.7.0+1 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:utopia_hooks/utopia_hooks.dart';
import 'package:utopia_hooks_query/utopia_hooks_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'),
        },
      ),
    );
  }
}
0
likes
150
points
8
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

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

License

BSD-2-Clause (license)

Dependencies

clock, collection, flutter, meta, utopia_hooks

More

Packages that depend on utopia_hooks_query