You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[go_router_builder] Proposal to improve how we handle extra parameters #117261
This comes with some major developer experience drawbacks in my opinion, among which, the biggest are:
forced named parameter
parameter type must be optional because it must be named and cannot be required
parameter must be named $extra
This leads to having roughly the following line every time you need to use the route (which btw wrongly shows a positional argument in the documentation):
Can you take a look at this issue and see if your use case is same ?
My proposed solution is exactly the same, yes.
Still, this issue aims to discuss broader fixes to extra - not only the variable name. Passing it as a positional parameter or requiring it if named and non-nullable would be what it really makes it more convenient than go_router.
At the moment I see too many compromises. I tried go_router_builder, I've seen it got in the way of what I was trying to achieve and went back to go_router
the changelog links this issue as it's resolved - is that actually the case?
I tried the example, it doesn't really work for me. I mean, the basic example works, but if I annotate a class using @freezed and generate the .fromJson and .toJson on it, and try to use such class as a typed route, the builder complains:
lib/router.dart go_router_builder
E The parameter type `MyFreezedClass` not have a supported fromJson definition.
package:something/src/my_freezed_class.dart:18:16
╷
18 │ abstract class MyFreezedClass with _$MyFreezedClass {
│ ^^^^^^^^^^^^^^^^^^^^^^^
╵
I'd be great to understand what's causing this, exactly.
Activity
dancamdev commentedon Dec 17, 2022
Specifically tackling the
We could define a decorator that's responsible for making sure the generator knows which parameter is the extra one, instead of relying on the name.
Ideally, something along this line:
Which would result in a much more clean way of using the route.
darshankawar commentedon Dec 19, 2022
@dancamdev
Can you take a look at this issue and see if your use case is same ?
dancamdev commentedon Dec 19, 2022
My proposed solution is exactly the same, yes.
Still, this issue aims to discuss broader fixes to
extra- not only the variable name. Passing it as a positional parameter or requiring it if named and non-nullable would be what it really makes it more convenient thango_router.At the moment I see too many compromises. I tried
go_router_builder, I've seen it got in the way of what I was trying to achieve and went back togo_routerdarshankawar commentedon Dec 19, 2022
Thanks for the update. I will keep this issue open and treat it as feature request based on above comment.
5 remaining items
[go_router] add initial json support #110781 (#9404)
[go_router_builder] Proposal: add json support, custom string encoder…
lucavenir commentedon Mar 13, 2026
the changelog links this issue as it's resolved - is that actually the case?
I tried the example, it doesn't really work for me. I mean, the basic example works, but if I annotate a class using
@freezedand generate the.fromJsonand.toJsonon it, and try to use such class as a typed route, the builder complains:I'd be great to understand what's causing this, exactly.
[go_router] add initial json support #110781 (flutter#9404)
[go_router_builder] Proposal: add json support, custom string encoder…
[go_router] add initial json support #110781 (flutter#9404)