Queue of Future in dart
It sounds like you are describing a Stream
- a series of asynchronous events which are ordered.
https://www.dartlang.org/guides/language/language-tour#handling-streamshttps://www.dartlang.org/guides/libraries/library-tour#stream
Create a StreamController
, and add messages to it as they come in:
var controller = StreamController<String>();// whenever you have a messagecontroller.add(message);
Listen on that stream and upload the messages:
await for(var messsage in controller.messages) { await uploadMessage(message);}