Try to search your question here, if you can't find : Ask Any Question Now ?

queue of key value future tasks

HomeCategory: stackoverflowqueue of key value future tasks
Avatarkundan asked 5 months ago

I want to create a queue of future tasks, with a key to avoid to add to the queue the same task already added.

This is my scenario:

  • async call to url1
  • async call to url1
  • async call to url2

What I need is:

  • add call to url1 to the queue and execute it
  • DO NOT add the second call to url1 to the queue and throw away it
  • add call to url2 to the queue, wait for call to url1 to be finished, and execute it

I read about StreamQueue and Queue, but I do not know if it fits for my needs.

Another structure I read about is await for with stream.

So I tried with something like:

await for (var url in stream) { // <--- I do not know how create this stream
  var url = Uri.https('', url);

  List<dynamic> tmpItems;

  try {
    http.Response res = await http.get(url);
    final data = json.decode(res.body);
    tmpItems = _parseItems(data["data"]);
  } catch(e) {

  if (this.mounted) {
    return setState(() {
      _items.addAll(tmpItems ?? []);

I do not know howto create stream and add to call to it.

1 Answers
Best Answer
AvatarMatthias answered 5 months ago
Your Answer

3 + 12 =

Popular Tags

WP Facebook Auto Publish Powered By :