Skip to content
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

[go _route] fragment parameter added #8232

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

AffanShaikhsurab
Copy link

@AffanShaikhsurab AffanShaikhsurab commented Dec 5, 2024

Description of Change

This PR addresses the need for fragments/hashes to be treated as first-party parameters within the go_router package, as highlighted in issue #150155. Previously, users had to manually append the fragment to the URL, which could lead to potential bugs. With this update, the fragment is now a dedicated parameter, allowing for a more seamless and bug-free integration.

Before:

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

After:

// Directly passing the fragment as a parameter
context.goNamed("details", fragment: 'https://a.url/that?i=mightuse');

// or

final location = GoRouterState.of(context).namedLocation(
  'details',
  fragment: 'section3',
);
context.go(location);

// or 

final location = context.namedLocation(
 'details',
 fragment: 'section3',
);
context.go(location);

Issues Fixed

This PR resolves issue #150155.


Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

hashes to URLs, whichcould lead to potential bugs.
This update introduces a dedicated fragment
parameter, allowing for more seamless and reliable URL navigation.
@AffanShaikhsurab AffanShaikhsurab changed the title Previously, users had to manually append fragments [go _route] fragment parameter added Dec 5, 2024
to remove the  Linux repo_checks error.
@chunhtai chunhtai requested a review from hannah-hyj December 5, 2024 22:40
@AffanShaikhsurab
Copy link
Author

@chunhtai @hannah-hyj Can you please tell me what improvements I should make?

AffanShaikhsurab and others added 3 commits December 10, 2024 07:32
namedLocation api

final location = context.namedLocation(
 'details',
 fragment: 'section3',
);
context.go(location);
configuration.namedLocation(
name,
pathParameters: pathParameters,
queryParameters: queryParameters,
);
) +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you drill down the fragment all the way to where uri is generated? at the end we want something like
Uri(...., fragment: fragment).toString();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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