Skip to content

[go_router_builder] Proposal to improve how we handle extra parameters #117261

Open
@dancamdev

Description

@dancamdev

In the current version of go_router_builder this is the only way to handle extra parameters to the route.

class PersonRouteWithExtra extends GoRouteData {
  PersonRouteWithExtra({this.$extra});
  final int? $extra;

  @override
  Widget build(BuildContext context) => PersonScreen(personId: $extra);
}

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):

PersonRouteWithExtra($extra: Person(name: 'Marvin', age: 42)).go(context);

Ideally, I would have a positional parameter or be able to have a custom named one.

The purpose of this issue is to discuss potential improvements on the API

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterp: go_router_builderThe go_router_builder packagepackageflutter/packages repository. See also p: labels.team-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions