Skip to content

[go_router] make fragments/hash a first-party parameter like query and path #150155

@TekExplorer

Description

@TekExplorer

What package does this bug report belong to?

go_router (also go_router_builder, but theres a dedicated issue for that)

Dependency versions

pubspec.lock
packages:
  ...
  go_router:
    dependency: "direct main"
    description:
      name: go_router
      sha256: abec47eb8c8c36ebf41d0a4c64dbbe7f956e39a012b3aafc530e951bdc12fe3f
      url: "https://pub.dev"
    source: hosted
    version: "14.1.4"
  ...

When I want to use hash/fragment to contain a url or path (for, say, a file manager or to contain the url for any number of reasons) I have to manually place the # in the location of context.go('/some/path/#fragment')

This is workable, but If we have parameters for paths and query parameters, why cant I have the same thing for my fragments?

The main issue for me is that I prefer to use named routes for consistency. There's nowhere to put my fragment, but i can still use query parameters? why is this a worse experience?

Additionally, i have an issue for hash/fragment support in go_router_builder #139387, but this cant progress if go_router doesnt have proper explicit support for it built in.

Honestly, I don't see why it doesnt just use the first-party Uri class, which will support everything.

Code sample

I hate that my current solution is stuck at this:

final location = context.namedLocation('some_route'); // const nested records
 // manually adding the fragment, hoping there arent any weird bugs surrounding it
context.replace('$location#https://a.url/that?i=mightuse');

Also! why is there no feature request template for first-party packages?
I'm stuck butchering this bug report...

Metadata

Metadata

Labels

Bot is counting down the days until it unassigns the issueP3Issues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Fluttergood first issueRelatively approachable for first-time contributorsp: go_routerThe go_router packagepackageflutter/packages repository. See also p: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions