-
-
Notifications
You must be signed in to change notification settings - Fork 129
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
Navigation history does not clear even after popping the page #646
Comments
@jeslinjacob1995 Is this still an issue, try updating to the latest beamer version, and the latest flutter version. |
Also add: backButtonDispatcher: BeamerBackButtonDispatcher( As a parameter to materialApp.router(...); |
@jeslinjacob1995 Is this fixed ? |
This is still happening for us in beamer 1.7.0. The history is cleared but pressing back on a web browser still takes us back to the last page we were on, but we expect a cleared history to result in a no-op for the back button. |
How do you clear the history? |
On web, we're using For instance, say I'm on page A and go to page B. If we beam back from B, then I expect B to be the last entry and so it gets removed. We then end up on A. However, from A, pressing the back arrow once more in the browser will go to back B! We can get around this, sort of, by using |
Here is a case with Beamer using beamBack compared to the browser's back arrow, on Chrome 129, Flutter 3.24.2, and Beamer 1.7.0: 2024-10-29.16-26-58.mp4In this video, I call As expected, the browser back button returns me to When I change the order of these operations, something different happens. From Here is the code I used for this: import 'package:beamer/beamer.dart';
import 'package:flutter/material.dart';
const int _numPages = 5;
const String _prefix = "/page";
final List<String> paths = [
for (int i = 0; i < _numPages; i++) "$_prefix$i",
];
String _depthToNamed(int depth) {
return paths[depth];
}
int _nameToDepth(String name) {
return int.parse(name.split(_prefix.substring(1)).last);
}
void main() {
Beamer.setPathUrlStrategy();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
MyApp({super.key});
final routerDelegate = BeamerDelegate(
initialPath: paths[0],
locationBuilder: BeamerLocationBuilder(
beamLocations: [
Locations(),
],
).call,
);
@override
Widget build(BuildContext context) {
return BeamerProvider(
routerDelegate: routerDelegate,
child: MaterialApp.router(
title: 'Beamer test',
debugShowCheckedModeBanner: false,
routerDelegate: routerDelegate,
routeInformationParser: BeamerParser(),
backButtonDispatcher: BeamerBackButtonDispatcher(
delegate: routerDelegate,
alwaysBeamBack: true,
fallbackToBeamBack: true,
),
),
);
}
}
class Screen extends StatelessWidget {
const Screen({
super.key,
required this.name,
this.depth = 0,
});
final String name;
final int depth;
void _beamToNext(BuildContext context) {
Beamer.of(context).beamToNamed(_depthToNamed(depth + 1));
}
void _back(BuildContext context) {
Beamer.of(context).beamBack();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: ListView(
children: [
Text(name),
if (depth + 1 < _numPages)
MaterialButton(
height: 60.0,
minWidth: 60.0,
onPressed: () => _beamToNext(context),
child: Text("Beam to ${depth + 1}"),
),
if (depth > 0)
MaterialButton(
height: 60.0,
minWidth: 60.0,
onPressed: () => _back(context),
child: Text("Beam back to ${depth - 1}"),
),
],
),
);
}
}
class MyNamedScreen extends StatelessWidget {
const MyNamedScreen({super.key, required this.name});
final String name;
@override
Widget build(BuildContext context) {
return Screen(
name: name,
depth: _nameToDepth(name),
);
}
}
class Locations extends BeamLocation<BeamState> {
@override
List<Pattern> get pathPatterns => paths;
@override
List<BeamPage> buildPages(BuildContext context, BeamState state) {
return [
for (String s in state.pathPatternSegments)
if (pathPatterns.contains('/$s'))
BeamPage(
key: ValueKey(s),
child: MyNamedScreen(
name: s,
),
)
];
}
} |
Describe the bug
Navigation history does not clear even after popping the page . If I pop from one page it will navigate correctly , but if i press browser back button it will take me to same page which i already popped
Beamer version: (e.g.
v0.14.1
,master
, ...)beamer: ^1.5.6
To Reproduce
Steps to reproduce the behavior:
from account statement page if i call
Navigator.of(context).maybePop();
it pops to correct page , but again if i press on browser back button it will take me to account statement pageExpected behavior
I am expecting that i should not go to the page which it already popped
I am running the code from flutter web with chrome browser
The text was updated successfully, but these errors were encountered: