Package selection guidance compiled from public package information, community data, and project usage.
The async_queue package ensures that a series of asynchronous tasks are executed sequentially, one after another, maintaining order and preventing concurrency issues. It provides a simple queue mechanism for handling async operations in a controlled manner, ideal for scenarios where task dependency or execution order is critical. Built with Dart, it integrates seamlessly into Flutter projects across all major platforms. The package is lightweight and focused on reliability, making it suitable for background processing, API call sequencing, or any use case requiring ordered async execution.
Use cases
Sequential API calls
Background task processing
Order-dependent operations
State management with async actions
Loading assets in sequence
Key features
Guarantees sequential execution
Simple queue interface
Cross-platform support
Lightweight and minimal dependencies
Thread-safe operation
Suitable for
Developers needing ordered async execution
Apps with dependent async workflows
Projects requiring predictable task scheduling
Flutter apps targeting multiple platforms
Teams prioritizing code simplicity
Considerations
Not for parallel task execution
Limited to single queue per instance
Requires careful management of queue lifecycle
Best suited for small to medium task batches
Does not handle retry logic or error recovery
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
Async Queue - ensure your list of async tasks execute in order
This dart package ensures your pack of async tasks executes in order, one after the other.
What's new in v3.0.0
addJob returns a Future — await individual job results directly, no more listener workarounds
Automatic retry on exceptions — jobs that throw are retried up to retryTime without manual retry() calls
onError callback — handle errors at the queue level: AsyncQueue(onError: (error, label) { ... })
Priority queue — addJob(..., priority: 10) to run important jobs first
final asyncQ = AsyncQueue();
asyncQ.addQueueListener((event) => print("$event"));
Await job result (v3.0.0+)
addJob returns a Future that completes with the job's return value. This works alongside previousResult — they serve different purposes.
final q = AsyncQueue.autoStart();
// Each addJob returns a Future you can await for its resultfinal userFuture = q.addJob((_) async {
returnawait api.getUser(); // returns "Sam"
});
// previousResult still chains between jobsfinal postsFuture = q.addJob((previousResult) async {
returnawait api.getPostsFor(previousResult);
});
final user = await userFuture; // "Sam"final posts = await postsFuture; // [Post, Post, ...]
Automatic retry on exceptions (v3.0.0+)
Jobs that throw are automatically retried up to retryTime times. You no longer need to catch errors and call retry() manually (though you still can for custom logic).
q.addJob((_) async {
// if this throws, it will be retried automaticallyreturnawait api.fetchData();
}, retryTime: 3);
onError callback (v3.0.0+)
Handle errors at the queue level without parsing events:
This package would be useful if you have multiple widgets in a screen or even in multiple screens that need to do some async requests that are related to each other.
For examples:
To make one request from a widget wait for another request from another widget to finish.
To avoid multiple requests from the front end hitting the backend in a short time, which would confuse the backend.