addEventBlockPop method
Adds an event that blocks pop navigation while processing.
Implementation
@nonVirtual
Future<void> addEventBlockPop(
BuildContext context,
T event, {
Callbacks? callbacks,
}) async {
if (_activeSoloEvents.contains(event.runtimeType)) {
log('MASTRO: EVENT_MODE_SOLO_(${event.runtimeType}) IS ALREADY RUNNING');
return;
}
if (event.mode == EventRunningMode.sequential) {
if (_activeSequentialEvents.contains(event.runtimeType)) {
log('MASTRO: EVENT_MODE_SEQUENTIAL_(${event.runtimeType}) GOT QUEUED');
_sequentialEventsQueue.add(_QueuedEvent(event, callbacks));
return;
} else {
_activeSequentialEvents.add(event.runtimeType);
}
} else if (event.mode == EventRunningMode.solo) {
_activeSoloEvents.add(event.runtimeType);
}
try {
await _awaitLoading(
future: () => event.implement(this, callbacks ?? Callbacks()),
context: context);
await _processSequentialEvents(event.runtimeType);
} catch (e) {
rethrow;
} finally {
if (event.mode == EventRunningMode.sequential) {
_activeSequentialEvents.remove(event.runtimeType);
} else if (event.mode == EventRunningMode.solo) {
_activeSoloEvents.remove(event.runtimeType);
}
}
}