nextStep method

Future<void> nextStep(
  1. BuildContext context
)

Implementation

Future<void> nextStep(BuildContext context) async {
  if (vm.isProcessing) return;

  bool isFormValid =
      pages[vm.currentStep].formKey.currentState?.validate() ?? true;
  var nextFunction = pages[vm.currentStep].onNext;

  if (!isFormValid) return;

  vm.isProcessing = true;
  vm.redraw();

  try {
    if (nextFunction != null) {
      isFormValid = await nextFunction() ?? true;
    }

    if (isFormValid && vm.currentStep < pages.length - 1) {
      vm.currentStep++;
      await _pageController.nextPage(
        duration: const Duration(milliseconds: 300),
        curve: Curves.easeInOut,
      );
    }
  } finally {
    vm.isProcessing = false;
    vm.redraw();
  }
}