@rknell
Hi,
What could be the reason that when I add a Future to the queue using add, it immediately runs the Future?
I didn’t put an await before queue.add.
I want to collect all of them first, and only when I run onComplete, I want them to execute one after another.
For example:
static Future<void> Function() createOfflineQueueTask({
required Future<void> Function() apiCall,
}) {
return () async {
print("Executing offline API call...");
await apiCall();
print("Finished executing offline API call...");
};
}
apiCall is Future<T?> Function()
queue.add(createOfflineQueueTask(apiCall: apiCall);
And when I want to run them:
queue.onComplete.then((_) {
remainingItemsStream.close();
queue?.dispose();
});
But thequeue.add runs them immediately instead before running the onComplete, why?
@rknell
Hi,
What could be the reason that when I add a Future to the queue using add, it immediately runs the Future?
I didn’t put an await before queue.add.
I want to collect all of them first, and only when I run onComplete, I want them to execute one after another.
For example:
apiCall is
Future<T?> Function()And when I want to run them:
But the
queue.addruns them immediately instead before running theonComplete, why?