start method

void start({
  1. int? startFrom,
  2. InsertOverlayCallback? insertOverlay,
})

If insertOverlay is not null will be used instead of insertOverlayCallback

insertOverlay must be not null if insertOverlayCallback is null

Implementation

void start({int? startFrom, InsertOverlayCallback? insertOverlay}) {
  if (log) _log('Started flow from index ${startFrom ?? 0}');

  assert(insertOverlay != null || insertOverlayCallback != null, "One of insertOverlay and insertOverlayCallback must be not null");
  _buildFocusWidgetKeysList();

  assert(startFrom == null || startFrom < _focusWidgetKeys.length);

  _currentStep = startFrom ?? 0;
  final ZwapTutorialStep _firstStep = steps[_currentStep!];

  if (_entry != null) {
    if (_entry!.mounted) _entry!.remove();
    _entry = null;
  }

  _entry = ZwapTutorialOverlayEntry(
    uniqueKey: GlobalKey(),
    builder: (_) => ZwapComplexTutorialWidget(
      log: log,
      index: _currentStep!,
      stepsCount: steps.length,
      focusWidgetKey: _focusWidgetKeys[_currentStep!],
      child: _firstStep.content,
      backgroundColor: _firstStep.backgroundColor,
      height: _firstStep.height,
      onBack: _currentStep == 0 ? null : back,
      onClose: () {
        if (_firstStep.onClose != null) _firstStep.onClose!();
        end();
      },
      onForward: _currentStep! + 1 == steps.length ? end : forward,
      overlayOffset: _firstStep.overlayOffset,
      showBack: _firstStep.showBack && _currentStep != 0,
      showSkip: _firstStep.showSkip,
      showEnd: _currentStep! + 1 == steps.length,
      width: _firstStep.width,
      blurRegion: _blurRegionKeys[_currentStep!],
      focusWidgetWrapper: _firstStep.focusWidgetWrapper,
      decorationDirection: _firstStep.decorationDirection,
      decorationTranslation: _firstStep.decorationTranslation,
    ),
  );

  _insertOverlay(_entry!, insertOverlay);
}