async_listenable
1.2.0, released 2 years ago by sonerik.dev
Provides a ValueListenable‑like API for async operations, exposing an AsyncSnapshot.
WASM-ready
What it does
It defines AsyncListenable, an interface that delivers AsyncSnapshot updates for Futures or Streams. AsyncNotifier implements this interface and lets you set or replace async sources, while AsyncListenableBuilder rebuilds widgets based on snapshot changes.
AI-written summary of version 1.2.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to observe async results outside the widget tree
- You want a ValueListenable‑style API for Futures/Streams
- You need to rebuild UI when async state (data, error, loading) changes
Skip it when
- A simple FutureBuilder or StreamBuilder is sufficient
- You require full state‑management solutions like Bloc or Riverpod
Strengths
- Integrates with existing ValueListenable patterns
- Handles both Future and Stream uniformly
- Provides snapshot (data, error, loading) out of the box
Weaknesses
- Limited to async snapshot handling, no broader state‑management features
- No code generation or advanced tooling
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
final notifier = AsyncNotifier<int>()..set(Future.value(42));
AsyncListenableBuilder(
notifier: notifier,
builder: (context, snapshot) => Text(snapshot.data?.toString() ?? ''),
);Alternatives
Packages that do the same job and could replace async_listenable.