nextStep method

Future<void> nextStep(
  1. BuildContext context
)

Implementation

Future<void> nextStep(BuildContext context) async {
  bool isFormValid =
      pages[vm.currentStep].formKey.currentState?.validate() ?? true;
  var nextFunction = pages[vm.currentStep].onNext;

  if (!isFormValid) return;

  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,
    );
    vm.redraw();
  }
}