Skip to content

[go_router_builder] Change mixin name #9626

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

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

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?

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] [go_router_builder] New "mixin" feature in go_router_builder 3.0.0 breaks separated routes logic
4 participants