next method
Future<void>
next({
- Duration? delay,
- Duration duration = const Duration(milliseconds: 150),
- Curve curve = Curves.easeIn,
override
Show the next step. If the current step equals the last step nothing will happen.
Implementation
@override
Future<void> next({
Duration? delay,
Duration duration = const Duration(milliseconds: 150),
Curve curve = Curves.easeIn,
}) async {
if (isLastStep(index) || !getIsGoNextEnabled()) {
return;
}
final delayUntil = DateTime.now().add(duration);
final oldIndex = index;
final newIndex = oldIndex + 1;
if (_onStepChanged != null) {
await _onStepChanged!(
oldIndex,
index,
);
}
final now = DateTime.now();
if (delay != null && delayUntil.isAfter(now)) {
final realDelay = Duration(
milliseconds:
delayUntil.millisecondsSinceEpoch - now.millisecondsSinceEpoch,
);
await Future.delayed(realDelay);
}
_index.add(newIndex);
await Future.wait([
stepControllers[newIndex].step.onShowing(),
stepControllers[oldIndex].step.onHiding(),
pageController.nextPage(
duration: duration,
curve: curve,
),
]);
await Future.wait([
stepControllers[newIndex].step.onShowingCompleted(),
stepControllers[oldIndex].step.onHidingCompleted(),
]);
}