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,
- Set up a function to store current position of the
PageView
in theSharedPreferences
. - On
initState
when app is opened, read this saved value, if the value exists, initialize thePageController
withinitialPage
parameter set to the last page left, if the value doesn't exist, keep it to defaultinitialPage
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.