dequeueAllMatching method
Remove and return all commands matching a predicate.
Implementation
List<QueuedCommand> dequeueAllMatching(
bool Function(QueuedCommand) predicate,
) {
final matched = <QueuedCommand>[];
final remaining = <QueuedCommand>[];
for (final cmd in _commandQueue) {
if (predicate(cmd)) {
matched.add(cmd);
} else {
remaining.add(cmd);
}
}
if (matched.isEmpty) return [];
_commandQueue
..clear()
..addAll(remaining);
_notifySubscribers();
for (final _ in matched) {
_logOperation(QueueOperation.dequeue);
}
return matched;
}