Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BeamGuard wrongly blocks beamTo #524

Open
schultek opened this issue May 25, 2022 · 2 comments
Open

BeamGuard wrongly blocks beamTo #524

schultek opened this issue May 25, 2022 · 2 comments
Labels
enhancement New feature or request proposal An idea
Milestone

Comments

@schultek
Copy link
Contributor

Describe the bug

I have a bug where I use a BeamGuard to redirect from one BeamLocation to another. The issue is that is never updates the pages and never builds the new BeamLocation.

After digging around, I found the responsible code lines:

package/lib/src/beam_guard.dart#L132-L136

The issue is that my redirected BeamLocations does not change the url location, but instead displays a different page for the same url.

I see why the specified lines are there but for me this does not work. Maybe the if block could also check whether the runtimeType of both BeamLocations are different.

If there is some other way that allows a BeamGuard to redirect to a BeamLocation without changing the url let me know.

Beamer version: 1.4.1

@slovnicki
Copy link
Owner

Hey old friend @schultek 🙂

I see what you mean... This is an interesting problem that should definitely allow more customization, e.g. that you can optionally customize what should BeamGuard treat as equal.

I'm planning to rework the guards for v2 so will assign this there. I plan to start working heavily on v2 next week.

@slovnicki slovnicki added enhancement New feature or request proposal An idea labels May 26, 2022
@slovnicki slovnicki added this to the v2 milestone May 26, 2022
@jpiabrantes
Copy link

I might have a related problem. I have two nested beamers. The top one has two guards: one that redirects unauth users to /signup and one that redirects users to /home.

The /home has another beamer, this beamer should also show a page when the url is /home:

BeamerDelegate _routerDelegate = BeamerDelegate(
    routeListener: (RouteInformation routeInfo, _) {
      print(_routerDelegate.currentBeamLocation.state.routeInformation.location);
      _routerDelegate.currentPages.forEach((element) {print(element);});
    } ,
      transitionDelegate: const NoAnimationTransitionDelegate(),
      locationBuilder: RoutesLocationBuilder(
          routes: {
        '/home': (context, state, data) => BeamPage(key: const ValueKey('home'), child: Container(color: Colors.yellow)),
        '/notifications': (context, state, data) =>
            BeamPage(key: const ValueKey('notifications'), child: Container(color: Colors.pink)),
      }));

The router listener prints:

>> /home
>> BeamPage("null", [<'not-found'>], null)

So the BeamPage does not match the location. This only happens when I arrive at /home coming from the Guard redirect.

Also noted that doing _routerDelegate.addListener gives different results than using the routeListener which is confusing - when should I use one thing or the other?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request proposal An idea
Projects
None yet
Development

No branches or pull requests

3 participants