Open
Description
I've noticed an issue that when I refresh on web, the state.params
in navigatorBuilder
are missing even tho the location
is set correctly.
Example:
Pattern: /:page
Url: localhost:4444/#/2
Result:
location
=/2
state.params['page']
=null
Expected Result:
location
=/2
state.params['page']
=2
Code Example
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
void main() {
runApp(MyApp());
}
final routes = [
GoRoute(
path: '/',
builder: (context, state) => const Page(
number: "1",
),
),
GoRoute(
path: '/:page',
builder: (context, state) => Page(number: state.params["page"] ?? "1"),
),
];
class MyApp extends StatelessWidget {
final _router = GoRouter(
routes: routes,
navigatorBuilder: (
BuildContext context,
GoRouterState state,
Widget child,
) {
print(state.location); // -> /2
print(state.params); // -> null :( expected: { 'page': '2' }
return child;
});
@override
Widget build(BuildContext context) {
return MaterialApp.router(
routeInformationProvider: _router.routeInformationProvider,
routeInformationParser: _router.routeInformationParser,
routerDelegate: _router.routerDelegate,
);
}
}
class Page extends StatelessWidget {
const Page({Key? key, required this.number}) : super(key: key);
final String number;
@override
Widget build(BuildContext context) {
return Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text("Page $number"),
ElevatedButton(
onPressed: () {
final next = (int.tryParse(number) ?? 1) + 1;
context.go("/$next");
},
child: Text("Next"))
],
));
}
}
Metadata
Metadata
Assignees
Labels
Important issues not at the top of the work listImportant issues not at the top of the work listFound to occur in 3.0Found to occur in 3.0Found to occur in 3.1Found to occur in 3.1The issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onThe go_router packageThe go_router packageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.Owned by Framework teamOwned by Framework team