Skip to content

[go_router] Add GoRouterState parameters to GoRouterData and rename replace methods #2848

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

Merged
merged 13 commits into from
Dec 19, 2022

Conversation

ValentinVignal
Copy link
Contributor

Resolves flutter/flutter#115955

After this is merged, I'll make another PR on [go_router_builder] to replace all the references of the deprecated redirect to redirectWithState

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

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

Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

LGTM

## 5.3.0

- Adds `redirectWithState` to `GoRouteData`.
- `GoRouteData.redirect` is now deprecated in favor of `GoRouteData.redirectWithState`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- `GoRouteData.redirect` is now deprecated in favor of `GoRouteData.redirectWithState`.
- Deprecates `GoRouteData.redirect` in favor of `GoRouteData.redirectWithState`.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated it in ✏️ Better changelog

@chunhtai chunhtai requested a review from johnpryan November 28, 2022 21:05
@johnpryan
Copy link
Contributor

Is it possible to keep the name redirect? Why are we shying away from a breaking change here?

@chunhtai
Copy link
Contributor

I agree with @johnpryan that we should probably just break it, but I am not sure if we can merge this without breaking the go_router_builder's build. It we can't we would need some sort of soft transition.

@chunhtai
Copy link
Contributor

yes it looks like we will probably be fine, all the reference in go_router_builder is doc. Let's just do a breaking change and write a migration guide and bump major version

@ValentinVignal
Copy link
Contributor Author

@chunhtai @johnpryan Sure I can make it a breaking change.
In that case,

  • Should I remove buildPage (deprecated) and rename buildPageWithState into buildPage?
  • Should I also add the parameter state to build?

@chunhtai
Copy link
Contributor

chunhtai commented Nov 30, 2022

Should I remove buildPage (deprecated) and rename buildPageWithState into buildPage?

We should definitrly remove buildPage, but I am not sure if we should rename it back, it feels it defeat the purpose of the @deprecated. WDYT @johnpryan

Should I also add the parameter state to build?

yes I think we may as well do all of these at once.

@ValentinVignal
Copy link
Contributor Author

ValentinVignal commented Dec 1, 2022

yes I think we may as well do all of these at once.

I've introduced the breaking changes in
💥 Remove xxxWithState and adds a the context and the state as a param…

We should definitrly remove buildPage, but I am not sure if we should rename it back, it feels it defeat the purpose of the @deprecated. WDYT @johnpryan

Yes, that is quite true haha. But since we are introducing breaking changes, why not? It also feels a bit weird that we are okay with breaking changes when there is no deprecation warning. But we are not when there was one (even if it was not really correct in this context).

yes it looks like we will probably be fine, all the reference in go_router_builder is doc. Let's just do a breaking change and write a migration guide and bump major version

For this, do you mean I should write a migration guide like this one? https://flutter.dev/go/go-router-v5-1-2-breaking-changes
I might need some indication on how to create/write one

@chunhtai
Copy link
Contributor

chunhtai commented Dec 1, 2022

@ValentinVignal you can make a copy of flutter.dev/go/template and follow the instruction above. once the doc is available through flutter.dev/go, you can then link the flutter.dev/go link to the go_router readme as part of this pr

@chunhtai
Copy link
Contributor

chunhtai commented Dec 1, 2022

you can also use something like kodify to format code block

@chunhtai
Copy link
Contributor

chunhtai commented Dec 1, 2022

also since you are doing it now, might as well consider including renaming in #2846

…with-state

# Conflicts:
#	packages/go_router/CHANGELOG.md
#	packages/go_router/pubspec.yaml
@ValentinVignal
Copy link
Contributor Author

ValentinVignal commented Dec 5, 2022

@chunhtai I've create a migration guide (see flutter/website#7910)

I've included the breaking change replace -> pushReplacement

@chunhtai chunhtai self-requested a review December 8, 2022 22:57
…with-state

# Conflicts:
#	packages/go_router/CHANGELOG.md
#	packages/go_router/pubspec.yaml
…with-state

# Conflicts:
#	packages/go_router/CHANGELOG.md
#	packages/go_router/pubspec.yaml
@ValentinVignal
Copy link
Contributor Author

@chunhtai @johnpryan Is there anything else you want me to do on this PR ?

Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

LGTM, can you add the migration guide to the readme?

@ValentinVignal ValentinVignal force-pushed the go-router/redirect-with-state branch from 09a2ecb to 6e6afbf Compare December 17, 2022 16:42
@ValentinVignal
Copy link
Contributor Author

LGTM, can you add the migration guide to the readme?

Sorry I forgot to do that.
I've included the link in the README in 📝 Add migration guide's link to the read me

@johnpryan johnpryan changed the title [go_router] Add redirectWithState [go_router] Add GoRouterState parameters to GoRouterData methods Dec 19, 2022
@johnpryan johnpryan changed the title [go_router] Add GoRouterState parameters to GoRouterData methods [go_router] Add GoRouterState parameters to GoRouterData and rename replace methods Dec 19, 2022
Copy link
Contributor

@johnpryan johnpryan left a comment

Choose a reason for hiding this comment

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

LGTM

@chunhtai chunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Dec 19, 2022
@auto-submit auto-submit bot merged commit 1cabcfb into flutter:main Dec 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App p: go_router
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[go_router_builder] GoRouteData redirect function has no context nor state parameters
3 participants