previous method

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

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

Implementation

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

  if (canPrevious()) {
    // 取得下一個步驟的動畫類型
    prevStep = getTargetRectGetter(_currentStepIndex - 1);
  }

  _usedAnimationType = prevStep?.animationType ?? widget.animationType;

  if (!canPrevious() || prevStep == null) {
    if (kDebugMode) {
      print('$_tag - 沒有上一步了');
    }
    return;
  }

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

  if (!mounted) {
    return;
  }

  _syncDisplay(prevStep);
}