volt 0.0.3
volt: ^0.0.3 copied to clipboard
Simple, fast, effortless data fetching and real-time updates
volt ⚡️ #
Effortlessly manage asynchronous data fetching, caching, and real-time data delivery with minimal code.
Features #
- ⚡️ Blazing-fast development with minimal boilerplate code
- 🚀 Fast in-memory caching for instant data access
- 💾 Robust disk caching for seamless offline support
- 🔄 Smart query deduplication to optimize network requests
- 🔮 Configurable auto-refetching to keep data fresh
- 📡 Real-time reactive updates across all listeners
- 🧩 Easy integration with existing Flutter projects
- 🧠 Compute isolate support for heavy deserialization tasks
- 📦 Simple and compact package for efficient state management
- 🔒 Built-in error handling, auto recovery and retry mechanisms
Install #
flutter pub add volt
copied to clipboard
Usage #
VoltQuery<Photo> photoQuery(String id) => VoltQuery(
queryKey: ["photo", id],
queryFn: () => fetch("https://jsonplaceholder.typicode.com/photos/$id"),
select: Photo.fromJson,
);
Widget build(BuildContext context) {
final photo = useQuery(photoQuery("1"));
return photo == null ? CircularProgressIndicator() : Text("Photo: ${photo.title}");
}
copied to clipboard
Configuration #
Widget build(BuildContext context) {
final queryClient = useMemoized(() => QueryClient(
// configuration options
));
return QueryClientProvider(
client: queryClient,
child: MyApp(),
);
}
copied to clipboard
Credits #
Volt's public API design was inspired by React Query, a popular data-fetching and state management library for React applications.