reportAnchorlessImageResult method

void reportAnchorlessImageResult({
  1. required int stepIndex,
  2. required bool ready,
})

Implementation

void reportAnchorlessImageResult({
  required int stepIndex,
  required bool ready,
}) {
  final state = _orchestrator.state;
  if (state == null || state.config.firstAnchorKey != null) return;
  if (ready) {
    _failedAnchorlessImages.remove(stepIndex);
    _readyAnchorlessImages.add(stepIndex);
  } else {
    _failedAnchorlessImages.add(stepIndex);
    final currentIndex = _activeConfigIndexes.isNotEmpty
        ? _activeConfigIndexes[_currentShownIndex]
        : 0;
    if (stepIndex != currentIndex && _waitingForAnchorlessStep != stepIndex) {
      return;
    }
  }
  WidgetsBinding.instance.addPostFrameCallback((_) {
    if (_orchestrator.state?.token != state.token) return;
    if (ready) {
      if (stepIndex == 0) _tryStart(state);
      if (_waitingForAnchorlessStep == stepIndex) {
        _waitingForAnchorlessStep = null;
        _advancing = false;
        _transition(forward: stepIndex > _currentShownIndex);
      }
    } else {
      _failAnchorlessImage(state, stepIndex);
    }
  });
  // Ensure an idle app processes the timeout's post-frame dismissal.
  WidgetsBinding.instance.scheduleFrame();
}