queue 3.1.0+2 copy "queue: ^3.1.0+2" to clipboard
queue: ^3.1.0+2 copied to clipboard

Queue up futures from multiple sources and await their return anywhere in your code.

example/queue_example.dart

import 'package:queue/queue.dart';

Future<void> main() async {
  final queue = Queue(delay: const Duration(milliseconds: 100));

  Future asyncMessage(String message) async {
    print(message);
  }

  unawaited(queue.add(() async {
    await asyncMessage("Message 1");
  }).then((result) => print("Message 1 complete")));

  await queue.add(() async {
    await asyncMessage("Message 2");
  });

  await Future.delayed(const Duration(milliseconds: 500));

  print('Message 2 complete');

  unawaited(queue.add(() async {
    await asyncMessage("Message 3");
    print("awaited message");
    throw Exception("Error");
  }).then((result) => print("Message 3 complete")));

  unawaited(queue
      .add(() async => asyncMessage("Message 4"))
      .then((result) => print("Message 4 complete")));
}

void unawaited(Future<void> future) {}
90
likes
130
pub points
96%
popularity

Publisher

unverified uploader

Queue up futures from multiple sources and await their return anywhere in your code.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

More

Packages that depend on queue