Skip to content

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

Merged
auto-submit[bot] merged 13 commits into
flutter:mainfrom
ValentinVignal:go-router/redirect-with-state
Dec 19, 2022
Merged

[go_router] Add GoRouterState parameters to GoRouterData and rename replace methods#2848
auto-submit[bot] merged 13 commits into
flutter:mainfrom
ValentinVignal:go-router/redirect-with-state

Conversation

@ValentinVignal

Copy link
Copy Markdown
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.

@chunhtai chunhtai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Comment thread packages/go_router/CHANGELOG.md Outdated
## 5.3.0

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

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

@chunhtai

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

chunhtai commented Nov 30, 2022

Copy link
Copy Markdown
Contributor

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

ValentinVignal commented Dec 1, 2022

Copy link
Copy Markdown
Contributor Author

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

chunhtai commented Dec 1, 2022

Copy link
Copy Markdown
Contributor

@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

chunhtai commented Dec 1, 2022

Copy link
Copy Markdown
Contributor

you can also use something like kodify to format code block

@chunhtai

chunhtai commented Dec 1, 2022

Copy link
Copy Markdown
Contributor

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

ValentinVignal commented Dec 5, 2022

Copy link
Copy Markdown
Contributor Author

@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
Copy Markdown
Contributor Author

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

@chunhtai chunhtai left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

@johnpryan johnpryan left a comment

Copy link
Copy Markdown
Contributor

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
creatorpiyush pushed a commit to creatorpiyush/packages that referenced this pull request Jun 10, 2026
…eplace methods (flutter#2848)

* ✨ Add redirectWithState method to GoRouteData

* ✅ Update the tests

* ⬆️ Increase version number

* ✏️ Better changelog

* 💥 Remove xxxWithState and adds a the context and the state as a parameter to all GoRouteData callbacks

* 📝 Update the change logs and version number

* 💥 Rename replace into pushReplacement

* 📝 Add pushReplacementNamed into change log

* 📝 Add migration guide's link to the read me
bisor0627 pushed a commit to bisor0627/packages that referenced this pull request Jun 19, 2026
…eplace methods (flutter#2848)

* ✨ Add redirectWithState method to GoRouteData

* ✅ Update the tests

* ⬆️ Increase version number

* ✏️ Better changelog

* 💥 Remove xxxWithState and adds a the context and the state as a parameter to all GoRouteData callbacks

* 📝 Update the change logs and version number

* 💥 Rename replace into pushReplacement

* 📝 Add pushReplacementNamed into change log

* 📝 Add migration guide's link to the read me
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