Skip to content

[Feature Request] Add page stack to the previous location's page stack #683

@Colman

Description

@Colman

Is your feature request related to a problem? Please describe.
I have an app with many different BeamLocations in it. Most of these locations and paths can only be accessed from one place in the app which makes things simple. However, there are a few routes that can be reached from many different places. For example, the login screen anytime you tap something that requires authentication, as well as a web view route that serves many different purposes.

My question is, what location should I add the login and web view routes too?

Solution 1 - If I make them have their own location, then once I beam to them, I lose the page states of the previous location I was at. So when I beam back, the route is correct, but the page state is gone.

Solution 2 - If I add the pages to every location, then I have to duplicate a lot of work since I have to consider every possible way that these routes can be reached. For example, I would have to add:

//Location 0
@override
List<Pattern> get pathPatterns {
  return [
    '/path',
    '/path/to',
    '/path/to/login',  //<-- Can reach the login screen from the /path/to route
    '/path/to/page',
    '/path/to/page/web-view', //<-- Can reach the web view screen from the /path/to/page route
  ];
}

//Location 1
@override
List<Pattern> get pathPatterns {
  return [
    '/another',
    '/another/path',
    '/another/path/login', //<-- Can reach the login screen from the /another/path route
    '/another/path/to',
    '/another/path/to/web-view', //<-- Can reach the web view screen from the /another/path/to route
  ];
}

...

//Location 2

Describe the solution you'd like
When calling beamTo or beamToNamed, add a parameter to join page stacks like so:

delegate.beamToNamed(
  //...
  joinPageStacks: true,
  //...
);

If this is set, the page stack of the new location will be stacked on top of the page stack of the current location, instead of disposing the current page stack in favor of the new one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions