runAtNextTime method

Future<void> runAtNextTime(
  1. OnboardingPage page,
  2. BuildContext context
)

To be called first thing when we click on "next" during onboarding.

The page parameter refers to the current page (before the next).

Implementation

Future<void> runAtNextTime(
  OnboardingPage page,
  BuildContext context,
) async {
  switch (page) {
    case OnboardingPage.WELCOME:
      await LoadingDialog.run<bool>(
        context: context,
        future: _downloadData().timeout(const Duration(seconds: 4)),
        title: AppLocalizations.of(
          context,
        ).onboarding_welcome_loading_dialog_title,
        dismissible: false,
      );
      return;
    case OnboardingPage.NOT_STARTED:
    case OnboardingPage.HOME_PAGE:
    case OnboardingPage.HEALTH_CARD_EXAMPLE:
    case OnboardingPage.ECO_CARD_EXAMPLE:
    case OnboardingPage.PREFERENCES_PAGE:
      // nothing special to do
      return;
    case OnboardingPage.PERMISSIONS_PAGE:
      // that was the last page of onboarding: after that, we clean up
      await _unloadData();
      return;
    case OnboardingPage.ONBOARDING_COMPLETE:
      // will never happen: we never click "next" on a "complete" page
      return;
  }
}