queue_it 0.9.0 queue_it: ^0.9.0 copied to clipboard
QueueIt makes dealing with queues easy. You can add multiple listeners, specify the number of concurrent items to process, view queue progress and more.
QueueIt #
QueueIt is designed to simplify the process of managing and processing queues in your Flutter and Dart applications.
Features #
- Queue management: Easily add, remove, and process items in a queue.
- Event listeners: Listen for updates to the queue and receive snapshots.
- Concurrency: Control the number of items processed simultaneously.
- Retries: Automatically retry failed items.
Usage #
Here's a basic example of how to use QueueIt:
import 'package:queue_it/queue_it.dart';
void main() {
final queue = QueueIt<int>(
parallel: 1,
retries: 3,
itemHandler: (item) async {
print('Handling item: ${item.id}');
/// Fake processing time
await Future.delayed(Duration(seconds: 1));
})
..onUpdate.listen((snapshot) {
print('Queue updated: ${snapshot.event.name}');
});
/// Add some items to the queue
queue.add(1);
queue.add(2);
queue.add(3);
/// start processing the queue
queue.start();
/// You can continue adding more items to the queue after it starts processing
queue.add(4);
queue.add(5);
}
For Flutter projects you will want to use flutter_queue_it, which listens to queue changes and rebuilds your widget tree:
QueueItWidget(
queue: _queue,
builder: (context, snapshot) {
/// `builder` will be called each time the queue updates
final items = _queue.items().toList();
return ListView.builder(
itemCount: items.length,
itemBuilder: (context, index) {
final item = items[index];
return ListTile(
title: Text('Item status: ${item.status.name}'),
);
},
);
},
);
For a more in-depth look at how to use QueueIt, check out the example project.
License #
QueueIt is licensed under the MIT License.