beamer
beamer copied to clipboard
BeamGuard Current Location
Describe the bug
Either I am misunderstanding how to get the current page URL in a beamguard, or there is a bug when in a stack. If you try to access the current page URL via (location.state as BeamState).uri
in a page stack it is always one behind after the first location.
For instance take the following stack new_game
-> casual
-> challenge
When I beam to new_game
the current location is /new_game
when I beam to new_game/casual
the current location is /new_game
when I beam to new_game/casual/challenge
the current location is /new_game/casual
Beamer version: master
To Reproduce Steps to reproduce the behavior:
-
Change these lines: https://github.com/slovnicki/beamer/blob/master/examples/guards/lib/main.dart#L227-L232
-
To
BeamGuard(
pathPatterns: ['/books', '/books/*'],
check: (context, location) {
print('current location ' +
(location.state as BeamState).uri.toString());
return context.read<AuthenticationNotifier>().isAuthenticated;
},
beamToNamed: (_, __) => '/login',
),
- and then navigate to a book.
Expected behavior
You will see the log only ever says current location /books
. If you had one more level deep on the stack you would see it update to something like /books/1
instead of /books/1/more-details
.
Desktop (please complete the following information): All
Smartphone (please complete the following information): All