Idea to Handle Complex Flutter Route
A) Screen A -> Screen B -> Screen C -> Screen D
B) Screen A -> Screen B -> Screen E -> Screen F -> Screen G
C) Screen I -> Screen E -> Screen F -> Screen G
In situation A, we have the normal flow. Situation B represents the second path of the normal flow. Situation C typically involves the reuse of certain screens in other partial flows. For example, during the user onboarding process at Screen I, there's a desire to reuse screens E, F, and G to create a user profile. These same screens, E, F, and G, are also used for updating the user's profile after they've signed in. These are common scenarios that often occur in app development.
Inspired by the concept of MS SQL's Begin/Rollback transaction, we can implement a similar approach in this case. Before the app runs a set of activities, we can set the [Route.settings.name] to 'beginTransaction.' Once the flow is completed, we can trigger a rollback, which essentially means undoing all the activities to the point where we began.