0

I am continuing to torture a GoRouter in my Android app project. There are a few "flows" in the app, like onboarding, connecting to a counterpart device etc - effectively, step based processes, where each step is represented by a separate "page" or "screen" in the app. I decided to do so mostly for compartmentalisation, since the matters I work with are a bit complex to grasp (for me), and Flutter involves tons of boilerplate code to just establish a certain look of elements. Maintaining less "screens" with more stateful code in them would be much more complex for me to manage.

In order to have a "birds' eye view" on these flows (like the exact sequence of onboarding steps) as well as to maintain some higher level logic about the flows themselves (like skipping the onboarding sequence altogether once it was done) I also use a finite state machine. Each page in each sequence is controlled by it and is not aware of its place in the bigger scheme of things, it can just tell the state machine that it is done with its area of responsibility. State machine then takes the user to the next screen, for which purpose it uses the .go() method of the GoRouter. There is no backwards movement anywhere, in each sequence user can only finish a small part of the bigger task and move on.

I also use some page transitions to give user a feeling of continuity in sequences. Page slide in from down below when starting a multistep sequence, or they do so from right to left when advancing within a sequence.

At the end of such sequence, I would also like the last page of the sequence to slide out from top to bottom to reveal the "main" page of the app underneath it. But I cannot grasp if that is even doable with the page transitions mechanism that I see in GoRouter. Looks like I can only animate the page that is being navigated to, and not the one I am doing this from.

Now, since the whole sequence is controlled by state machine and there is no real "returning" from anywhere, just advancing along the sequence (which coincidentally might bring you "back" to its beginning screen), I don't seem to have a way to conditionally call .pop() in such situations.

Have I painted myself into a corner? Is there a way to animate a page transition in GoRouter such that it looks like I am returning to some page and not advancing to it?

user20532
  • 55
  • 5

0 Answers0