Home > Enterprise >  I need to be able to load multiple pages at the same time or customize the page stack in some other
I need to be able to load multiple pages at the same time or customize the page stack in some other

Time:03-15

I have a 3-step registration process. If the application is stopped during any of these phases, it will resume from the last screen shown on the next restart. By doing so, however, I am no longer able to call the Navigator.pop because the pages before the one opened are never loaded. Is it possible to load multiple pages at once? Or create an always default page stack?

CodePudding user response:

If the registration process is a three step process, use PageView with three screens passed to it, when moving to next, use the PageController.jumpTo(pageNumber).

Now, to resume the registration process to the last page left,

  1. Set up a function to store current position of the PageView in the SharedPreferences.
  2. On initState when app is opened, read this saved value, if the value exists, initialize the PageController with initialPage parameter set to the last page left, if the value doesn't exist, keep it to default initialPage value (0). This way it will always show the last page selected, resuming the registration process.

You can also load the last entered values in the screens passed to the PageView.

This way, without using any third party package, you can create proper mechanism which fulfills your requirement.

  • Related