Skip to content

Conversation

@StevenSorial
Copy link
Contributor

@StevenSorial StevenSorial commented Jul 14, 2025

Fixes #170650

This PR fixes workflows that relied on putting child routes in files different than parent files, which resulted in the (private) mixin being generated in a different file than the route itself.

To avoid releasing a new major version in such a short period, this PR makes the mixin public only if needed. Admittedly makes the behavior somewhat unexpected for the user. @chunhtai @hannah-hyj I will leave that decision for you, whether that's ok or I should make it always public and release a major version instead.

Since this change just fixes a use-case that already didn't compile in 3.x.x, this PR doesn't bump the major version.

Pre-Review Checklist

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

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2 3

@ManuelRauber
Copy link

Works for me for the moment. :)

@StevenSorial StevenSorial marked this pull request as ready for review July 19, 2025 20:25
@StevenSorial StevenSorial requested a review from chunhtai as a code owner July 19, 2025 20:25
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.

change makes sense to me. we should also update the readme

@StevenSorial
Copy link
Contributor Author

change makes sense to me. we should also update the readme

@chunhtai, so are you ok with the approach where the mixin will be public /private based on the routes configuration? or does it seem too inconsistent for you?

If you are ok with the current approach, I will add a note in the readme

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.

I think let's just make this a breaking change. I see no reason to not make this a public mixin. WDYT?

String get _mixinName {
// If the routeDataClass is in a different file, we need to make the mixin public
final Uri routeUri = routeDataClass.source.uri;
return routeUri != targetUri ? '\$$_className' : '_\$$_className';
Copy link
Contributor

Choose a reason for hiding this comment

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

thinking about it more, let's just do a breaking change and make this a public class. having dealing with cases in both seems counter intuitive since we are maintaining a versioned package.

@StevenSorial
Copy link
Contributor Author

I think let's just make this a breaking change. I see no reason to not make this a public mixin. WDYT?

@chunhtai My ideal scenario would be to improve the Generator to be able track the routes in different files without an annotation in every route file

// parent_route.dart

@TypedGoRoute<ParentRoute>(
  path: '/',
  routes: [TypedGoRoute<SubRoute>(path: 'sub')],
)
class ParentRoute extends GoRouteData with _$ParentRoute {
}

// sub_route.dart

class SubRoute extends GoRouteData with _$SubRoute {}

in my ideal scenario, the generator would be able to generate parent_route.g.dart containing _$ParentRoute mixin, and sub_route.g.dart containing _$SubRoute mixin.

I looked into this, and it seems that it will require so much work and possibly getting rid of SharedPartBuilder. Is that assumption correct?

@mustafamasri1
Copy link

any update?

@StevenSorial
Copy link
Contributor Author

StevenSorial commented Aug 14, 2025

@chunhtai could you please answer my last question?

@mustafamasri1
Copy link

mustafamasri1 commented Aug 15, 2025

I think let's just make this a breaking change. I see no reason to not make this a public mixin. WDYT?

@chunhtai My ideal scenario would be to improve the Generator to be able track the routes in different files without an annotation in every route file

// parent_route.dart

@TypedGoRoute<ParentRoute>(
  path: '/',
  routes: [TypedGoRoute<SubRoute>(path: 'sub')],
)
class ParentRoute extends GoRouteData with _$ParentRoute {
}

// sub_route.dart

class SubRoute extends GoRouteData with _$SubRoute {}

in my ideal scenario, the generator would be able to generate parent_route.g.dart containing _$ParentRoute mixin, and sub_route.g.dart containing _$SubRoute mixin.

I looked into this, and it seems that it will require so much work and possibly getting rid of SharedPartBuilder. Is that assumption correct?

This idea is already created, check this comment in #122258

@chunhtai
Copy link
Contributor

My concern is that developer need to be aware of 2 option, _$Route and $Route and remember when the _$Route is allow and when it is not. We should just give them one choice, and it seems $Route for all cases?

in my ideal scenario, the generator would be able to generate parent_route.g.dart containing _$ParentRoute mixin, and sub_route.g.dart containing _$SubRoute mixin.

That will work as well

I looked into this, and it seems that it will require so much work and possibly getting rid of SharedPartBuilder. Is that assumption correct?

How so?

@mustafamasri1
Copy link

any update?

@StevenSorial StevenSorial requested a review from chunhtai August 23, 2025 09:35
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 write a breaking change doc?

@chunhtai chunhtai requested a review from hannah-hyj August 25, 2025 16:48
@StevenSorial
Copy link
Contributor Author

LGTM, can you write a breaking change doc?

Sure. How can I do that?

@chunhtai
Copy link
Contributor

  1. You can make a doc similar to this one
    https://docs.google.com/document/d/1E4B5nMDEvsqQiCo-Ki9LohocLFC88X398-AiLXRQhwU/edit?tab=t.0

  2. share with everyone for view only

  3. Add an golink entry in https://github.com/flutter/website/blob/main/firebase.json

  4. add the breaking change doc to Readme of go_router_builder similar to what we did in go_router

sfshaza2 pushed a commit to flutter/website that referenced this pull request Aug 27, 2025
breaking change for go_router_builder v4.0.0
Preparing for [#9626](flutter/packages#9626)

## Presubmit checklist

- [x] If you are unwilling, or unable, to sign the CLA, even for a
_tiny_, one-word PR, please file an issue instead of a PR.
- [x] If this PR is not meant to land until a future stable release,
mark it as draft with an explanation.
- [x] This PR follows the [Google Developer Documentation Style
Guidelines](https://developers.google.com/style)—for example, it doesn't
use _i.e._ or _e.g._, and it avoids _I_ and _we_ (first-person
pronouns).
- [x] This PR uses [semantic line
breaks](https://github.com/dart-lang/site-shared/blob/main/doc/writing-for-dart-and-flutter-websites.md#semantic-line-breaks)
  of 80 characters or fewer.
@StevenSorial StevenSorial requested a review from chunhtai August 27, 2025 17:35
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

@chunhtai chunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 27, 2025
@auto-submit
Copy link
Contributor

auto-submit bot commented Aug 27, 2025

autosubmit label was removed for flutter/packages/9626, because This PR has not met approval requirements for merging. The PR author is not a member of flutter-hackers and needs 1 more review(s) in order to merge this PR.

  • Merge guidelines: A PR needs at least one approved review if the author is already part of flutter-hackers or two member reviews if the author is not a flutter-hacker before re-applying the autosubmit label. Reviewers: If you left a comment approving, please use the "approve" review action instead.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 27, 2025
@StevenSorial
Copy link
Contributor Author

@chunhtai The submit label got removed

@chunhtai
Copy link
Contributor

waiting for another review

Copy link
Member

@hannah-hyj hannah-hyj left a comment

Choose a reason for hiding this comment

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

LGTM

@hannah-hyj hannah-hyj added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 29, 2025
@auto-submit auto-submit bot merged commit 3db5adc into flutter:main Aug 29, 2025
80 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 1, 2025
github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request Sep 1, 2025
flutter/packages@a3f09e5...3db5adc

2025-08-29 [email protected] [go_router_builder] Change mixin name
(flutter/packages#9626)
2025-08-29 [email protected] [go_router] Add state restoration
topic to documentation (flutter/packages#9867)
2025-08-29 [email protected] [camera_avfoundation]
Implementation swift migration - part 12 (flutter/packages#9781)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
@StevenSorial StevenSorial deleted the public-mixin branch September 2, 2025 17:11
mboetger pushed a commit to mboetger/flutter that referenced this pull request Sep 18, 2025
flutter/packages@a3f09e5...3db5adc

2025-08-29 [email protected] [go_router_builder] Change mixin name
(flutter/packages#9626)
2025-08-29 [email protected] [go_router] Add state restoration
topic to documentation (flutter/packages#9867)
2025-08-29 [email protected] [camera_avfoundation]
Implementation swift migration - part 12 (flutter/packages#9781)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
korca0220 pushed a commit to korca0220/flutter that referenced this pull request Sep 22, 2025
flutter/packages@a3f09e5...3db5adc

2025-08-29 [email protected] [go_router_builder] Change mixin name
(flutter/packages#9626)
2025-08-29 [email protected] [go_router] Add state restoration
topic to documentation (flutter/packages#9867)
2025-08-29 [email protected] [camera_avfoundation]
Implementation swift migration - part 12 (flutter/packages#9781)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Jaineel-Mamtora pushed a commit to Jaineel-Mamtora/flutter_forked that referenced this pull request Sep 24, 2025
flutter/packages@a3f09e5...3db5adc

2025-08-29 [email protected] [go_router_builder] Change mixin name
(flutter/packages#9626)
2025-08-29 [email protected] [go_router] Add state restoration
topic to documentation (flutter/packages#9867)
2025-08-29 [email protected] [camera_avfoundation]
Implementation swift migration - part 12 (flutter/packages#9781)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
lucaantonelli pushed a commit to lucaantonelli/flutter that referenced this pull request Nov 21, 2025
flutter/packages@a3f09e5...3db5adc

2025-08-29 [email protected] [go_router_builder] Change mixin name
(flutter/packages#9626)
2025-08-29 [email protected] [go_router] Add state restoration
topic to documentation (flutter/packages#9867)
2025-08-29 [email protected] [camera_avfoundation]
Implementation swift migration - part 12 (flutter/packages#9781)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
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_builder

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[go_router] [go_router_builder] New "mixin" feature in go_router_builder 3.0.0 breaks separated routes logic

5 participants