processLifecycleEvents method

void processLifecycleEvents()
inherited

Implementation

void processLifecycleEvents() {
  assert(_blocked.isEmpty);
  var repeatLoop = true;
  while (repeatLoop) {
    repeatLoop = false;
    for (final event in _queue) {
      final child = event.child!;
      final parent = event.parent!;
      if (_blocked.contains(identityHashCode(child)) ||
          _blocked.contains(identityHashCode(parent))) {
        continue;
      }

      final status = switch (event.kind) {
        _LifecycleEventKind.add => child.handleLifecycleEventAdd(parent),
        _LifecycleEventKind.remove =>
          child.handleLifecycleEventRemove(parent),
        _LifecycleEventKind.move => child.handleLifecycleEventMove(parent),
        _LifecycleEventKind.unknown => LifecycleEventStatus.done,
      };

      switch (status) {
        case LifecycleEventStatus.done:
          _queue.removeCurrent();
          repeatLoop = true;
        case LifecycleEventStatus.block:
          _blocked.add(identityHashCode(child));
          _blocked.add(identityHashCode(parent));
        default:
      }
    }
    _blocked.clear();
  }

  if (!hasLifecycleEvents && _lifecycleEventsCompleter != null) {
    _lifecycleEventsCompleter!.complete();
    _lifecycleEventsCompleter = null;
  }
}