pruneCompleted method
Remove completed/cancelled/failed tasks from the registry.
Implementation
int pruneCompleted() {
final toRemove = _tasks.entries
.where((e) => e.value.isTerminal)
.map((e) => e.key)
.toList();
for (final id in toRemove) {
_tasks.remove(id);
}
return toRemove.length;
}