next method

  1. @override
Future<void> next({
  1. bool waitCurrentEnd = true,
  2. bool currentEndWithAnimation = true,
  3. FutureCallback? onCurrentEndComplete,
})
override

waitCurrentEnd - 是否等待當前步驟關閉後再跳下個步驟 currentEndWithAnimation - 關閉當前步驟是否有動畫 onCurrentEndComplete - 當前步驟完全關閉後回調

Implementation

@override
Future<void> next({
  bool waitCurrentEnd = true,
  bool currentEndWithAnimation = true,
  FutureCallback? onCurrentEndComplete,
}) async {
  NextStepInfo? nextStep;

  if (canNext()) {
    // 取得下一個步驟的動畫類型
    nextStep = getTargetRectGetter(_currentStepIndex + 1);
  }

  _usedAnimationType = nextStep?.animationType ?? widget.animationType;

  if (waitCurrentEnd) {
    await _endFocus(
      withAnimation: currentEndWithAnimation,
      nextAnimationType: nextStep?.animationType,
    );
    await onCurrentEndComplete?.call();
  } else {
    _endFocus(
      withAnimation: currentEndWithAnimation,
      nextAnimationType: nextStep?.animationType,
    ).then((value) {
      onCurrentEndComplete?.call();
    });
  }

  if (!canNext() || nextStep == null) {
    if (kDebugMode) {
      print('$_tag - 教學結束');
    }
    finish();
    return;
  }

  _currentStepIndex++;

  if (_currentStepIndex != 0 && _isFirstShow) {
    _isFirstShow = false;
  }

  if (!mounted) {
    return;
  }

  _syncDisplay(nextStep);
}