waitForPendingEvents method
Wait for all pending dispatchEvent operations to complete
Implementation
Future<void> waitForPendingEvents() async {
if (_pendingDispatchEvents.isEmpty) return;
// Create a copy of current pending events to avoid concurrent modification
List<Future<void>> currentPending = List.from(_pendingDispatchEvents);
await Future.wait(currentPending);
}