Skip to content

[go_router_builder] Support extension types - #9458

Merged
auto-submit[bot] merged 16 commits into
flutter:mainfrom
koji-1009:feat/extension_type
Aug 13, 2025
Merged

auto-submit[bot] merged 16 commits into
flutter:mainfrom
koji-1009:feat/extension_type

Conversation

@koji-1009

@koji-1009 koji-1009 commented Jun 20, 2025 •

Copy link
Copy Markdown
Contributor

fix flutter/flutter#170870

Extended type_helpers.dart to support Dart extension types.

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

@koji-1009
koji-1009 marked this pull request as ready for review June 20, 2025 04:07
@koji-1009
koji-1009 requested a review from chunhtai as a code owner June 20, 2025 04:07
return '$stateValue as $castType';
}

final String parseTypeName =

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.

Should we guard against no primitive type? since this is following by a hardcode tryParse, may as well only allow certain numeric types?

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 think you are right in pointing this out. I restricted the type and handled it correctly. 61901a3

@koji-1009
koji-1009 requested a review from chunhtai June 26, 2025 13:09

@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.

code lgtm, just need an example

## Type conversions

The code generator can convert simple types like `int` and `enum` to/from the
The code generator can convert simple types like `int`, `enum`, and `extension type` to/from the

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.

We should add a new example in example/ folder

@chunhtai
chunhtai requested a review from hannah-hyj July 2, 2025 18:36

@hannah-hyj hannah-hyj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thank you for writing the examples!

@@ -0,0 +1,408 @@
// Copyright 2013 The Flutter Authors. All rights reserved.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

typo in the file name: typs-> types

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.

Sorry! I fixed. c57f3d0

}

/// A type helper for extension types.
/// Suppoted extension types are:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: Suppoted-> Supported

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.

Sorry, I fixed! c57f3d0

@koji-1009
koji-1009 requested a review from chunhtai July 10, 2025 01:39
@justinmc

Copy link
Copy Markdown
Contributor

@koji-1009 You had a failure that I just reran. If it still fails, can you take a look? Maybe you just need to push a merge commit / rebase.

@koji-1009

Copy link
Copy Markdown
Contributor Author

@justinmc
Thanks for mention. The error message is following.

https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8708712639707483713/+/u/Run_package_tests/CHANGELOG_and_version_validation/stdout?format=raw

--packages-for-branch: running on branch "HEAD".
Running for all packages that have diffs relative to "d9d3191ea6cf5b2a040b3368171112c1da736483"

Changed packages: go_router_builder
[0:00] Running for packages/go_router_builder...
  3.0.1 -> 3.1.0
  When bumping the version for release, the NEXT section should be incorporated into the new version's release notes.


The following packages had errors:
  packages/go_router_builder:
    CHANGELOG.md failed validation.
See above for full details.

This “NEXT” section was described at #9453. Because of this, go_router_builder is in a difficult situation for minor version upgrades until the build issue is resolved.

I believe that the problem of build could have been solved at #9649.

@koji-1009

Copy link
Copy Markdown
Contributor Author

Added examples file. Merged the main branch, and all tests passed 👍

@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

@chunhtai chunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 13, 2025
@auto-submit
auto-submit Bot merged commit eab16dd into flutter:main Aug 13, 2025
@koji-1009
koji-1009 deleted the feat/extension_type branch August 13, 2025 23:40
CaoGiaHieu-dev added a commit to CaoGiaHieu-dev/packages that referenced this pull request Aug 14, 2025
* main: (56 commits)
  [go_router_builder] Support extension types (flutter#9458)
  Roll Flutter from e2a347b to 34c2a3b (41 revisions) (flutter#9803)
  [go_router_builder] Migrate to Element2 API and update dependencies (flutter#9649)
  [in_app_purchase_storekit] Add support for quantity in consumable product purchases (#171570) (flutter#9698)
  [pigeon] Improves documentation of `ProxyApi` and moves helper functions to a separate file (flutter#9756)
  Roll Flutter from 1590543 to e2a347b (1 revision) (flutter#9784)
  [camera_avfoundation] Implementation swift migration - part 11 (flutter#9690)
  [camera_avfoundation] Fix crash when streaming while recording (flutter#9691)
  Roll Flutter from 3821790 to 1590543 (14 revisions) (flutter#9780)
  Roll Flutter from 92a6bfb to 3821790 (17 revisions) (flutter#9778)
  [video_player] Improve KVO handling on iOS (flutter#9718)
  [dependabot]: Bump the test-dependencies group across 15 directories with 7 updates (flutter#9736)
  Roll Flutter from 9de63a0 to 92a6bfb (11 revisions) (flutter#9769)
  [google_maps_flutter_platform_interface] Add Advanced markers support (flutter#9737)
  [camera_android_camerax] Re-land "Force new Surface for each SurfaceRequest" (flutter#9760)
  [google_maps_flutter] Add ability to perform Google Maps SDK warmup (flutter#9674)
  Roll Flutter from 59fc766 to 9de63a0 (6 revisions) (flutter#9764)
  [webview_flutter_wkwebview] Extended Web View API on iOS to add flexibility when working with local HTML content (flutter#8787)
  [local_auth] Differentiate iOS authentication errors (flutter#9705)
  manual roll to 59fc766 (flutter#9758)
  ...

# Conflicts:
#	packages/go_router_builder/lib/src/type_helpers.dart
#	packages/go_router_builder/pubspec.yaml
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 14, 2025
github-merge-queue Bot pushed a commit to flutter/flutter that referenced this pull request Aug 14, 2025
flutter/packages@6cb9113...09533b7

2025-08-14 [email protected] Roll Flutter from
34c2a3b to f4334d2 (18 revisions) (flutter/packages#9807)
2025-08-14 [email protected] Add review agent style guidelines to
.gemini/styleguide.md (flutter/packages#9805)
2025-08-13 [email protected] [go_router_builder] Support extension
types (flutter/packages#9458)
2025-08-13 [email protected] Roll Flutter from
e2a347b to 34c2a3b (41 revisions) (flutter/packages#9803)

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
SydneyBao pushed a commit to SydneyBao/flutter that referenced this pull request Aug 14, 2025
flutter/packages@6cb9113...09533b7

2025-08-14 [email protected] Roll Flutter from
34c2a3b to f4334d2 (18 revisions) (flutter/packages#9807)
2025-08-14 [email protected] Add review agent style guidelines to
.gemini/styleguide.md (flutter/packages#9805)
2025-08-13 [email protected] [go_router_builder] Support extension
types (flutter/packages#9458)
2025-08-13 [email protected] Roll Flutter from
e2a347b to 34c2a3b (41 revisions) (flutter/packages#9803)

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
ksokolovskyi pushed a commit to ksokolovskyi/flutter that referenced this pull request Aug 19, 2025
flutter/packages@6cb9113...09533b7

2025-08-14 [email protected] Roll Flutter from
34c2a3b to f4334d2 (18 revisions) (flutter/packages#9807)
2025-08-14 [email protected] Add review agent style guidelines to
.gemini/styleguide.md (flutter/packages#9805)
2025-08-13 [email protected] [go_router_builder] Support extension
types (flutter/packages#9458)
2025-08-13 [email protected] Roll Flutter from
e2a347b to 34c2a3b (41 revisions) (flutter/packages#9803)

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
mboetger pushed a commit to mboetger/flutter that referenced this pull request Sep 18, 2025
flutter/packages@6cb9113...09533b7

2025-08-14 [email protected] Roll Flutter from
34c2a3b to f4334d2 (18 revisions) (flutter/packages#9807)
2025-08-14 [email protected] Add review agent style guidelines to
.gemini/styleguide.md (flutter/packages#9805)
2025-08-13 [email protected] [go_router_builder] Support extension
types (flutter/packages#9458)
2025-08-13 [email protected] Roll Flutter from
e2a347b to 34c2a3b (41 revisions) (flutter/packages#9803)

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@6cb9113...09533b7

2025-08-14 [email protected] Roll Flutter from
34c2a3b to f4334d2 (18 revisions) (flutter/packages#9807)
2025-08-14 [email protected] Add review agent style guidelines to
.gemini/styleguide.md (flutter/packages#9805)
2025-08-13 [email protected] [go_router_builder] Support extension
types (flutter/packages#9458)
2025-08-13 [email protected] Roll Flutter from
e2a347b to 34c2a3b (41 revisions) (flutter/packages#9803)

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@6cb9113...09533b7

2025-08-14 [email protected] Roll Flutter from
34c2a3b to f4334d2 (18 revisions) (flutter/packages#9807)
2025-08-14 [email protected] Add review agent style guidelines to
.gemini/styleguide.md (flutter/packages#9805)
2025-08-13 [email protected] [go_router_builder] Support extension
types (flutter/packages#9458)
2025-08-13 [email protected] Roll Flutter from
e2a347b to 34c2a3b (41 revisions) (flutter/packages#9803)

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
creatorpiyush pushed a commit to creatorpiyush/packages that referenced this pull request Jun 10, 2026
fix flutter/flutter#170870

Extended `type_helpers.dart` to support [Dart extension types](https://dart.dev/language/extension-types).

## Pre-Review Checklist

[^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.
auto-submit Bot pushed a commit that referenced this pull request Sep 2, 2026
Adds build-time detection of routes that resolve to the same URL pattern. `go_router` matches the first route that fits, so a duplicated path silently makes the later route's page unreachable, and `LaterRoute().go(context)` navigates you to `EarlierRoute`'s page instead. Today nothing surfaces that until you run into the issue at runtime.

Reported as a warning by default, and  new `duplicate_route_paths` builder option accepts `warning` (the default), `error`, and `ignore`, so teams whose duplicates are mistakes can fail the build instead.

**Before**, `go_router_builder`'s own example app built clean despite two duplicate registrations:

```
$ dart run build_runner build
[INFO] Succeeded after 14s with 36 outputs
```

**After**:

```
$ dart run build_runner build
W go_router_builder on lib/all_types.dart:
  Duplicate route path detected: DoubleRoute is declared more than once at "double-route/:requiredDoubleField".
```

That duplicate was real. `DoubleRoute` had been registered twice since #2395 (2022) and `DoubleExtensionRoute` since #9458 (2025). Both were unreachable, and this PR removes them. The only change to the generated output is the dead route entries.

What competes for a URL namespace:

- Sibling routes, with path parameters normalized, so `product/:id` and `product/:productId` are one pattern.
- Routes inside shell routes and `StatefulShellRoute` branches, since those own no path of their own and their children compete with the routes around them.
- Relative routes, which own their path like any other route, so `/home/details/edit` and `/home/edit` stay distinct.
- Routes from separate annotations, since the generated `$appRoutes` collects them into one list. Scope is the library, `part` files included.

**Testing:** five new golden inputs in `test_inputs/` cover sibling duplicates, parameter-name-only differences, `StatefulShellRoute` branches, relative routes, cross-annotation duplicates, and the sound same-class grouping case. The golden harness gained two optional companion files per input, documented in the README: `<name>.dart.options` supplies JSON builder options so each severity is exercised through the real option-parsing path, and `<name>.dart.warnings` asserts logged warnings, with an empty file asserting silence.

Fixes flutter/flutter#190741

## Pre-Review Checklist

**Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

[^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.
victorsanni pushed a commit to victorsanni/packages that referenced this pull request Sep 9, 2026
…er#12399)

Adds build-time detection of routes that resolve to the same URL pattern. `go_router` matches the first route that fits, so a duplicated path silently makes the later route's page unreachable, and `LaterRoute().go(context)` navigates you to `EarlierRoute`'s page instead. Today nothing surfaces that until you run into the issue at runtime.

Reported as a warning by default, and  new `duplicate_route_paths` builder option accepts `warning` (the default), `error`, and `ignore`, so teams whose duplicates are mistakes can fail the build instead.

**Before**, `go_router_builder`'s own example app built clean despite two duplicate registrations:

```
$ dart run build_runner build
[INFO] Succeeded after 14s with 36 outputs
```

**After**:

```
$ dart run build_runner build
W go_router_builder on lib/all_types.dart:
  Duplicate route path detected: DoubleRoute is declared more than once at "double-route/:requiredDoubleField".
```

That duplicate was real. `DoubleRoute` had been registered twice since flutter#2395 (2022) and `DoubleExtensionRoute` since flutter#9458 (2025). Both were unreachable, and this PR removes them. The only change to the generated output is the dead route entries.

What competes for a URL namespace:

- Sibling routes, with path parameters normalized, so `product/:id` and `product/:productId` are one pattern.
- Routes inside shell routes and `StatefulShellRoute` branches, since those own no path of their own and their children compete with the routes around them.
- Relative routes, which own their path like any other route, so `/home/details/edit` and `/home/edit` stay distinct.
- Routes from separate annotations, since the generated `$appRoutes` collects them into one list. Scope is the library, `part` files included.

**Testing:** five new golden inputs in `test_inputs/` cover sibling duplicates, parameter-name-only differences, `StatefulShellRoute` branches, relative routes, cross-annotation duplicates, and the sound same-class grouping case. The golden harness gained two optional companion files per input, documented in the README: `<name>.dart.options` supplies JSON builder options so each severity is exercised through the real option-parsing path, and `<name>.dart.warnings` asserts logged warnings, with an empty file asserting silence.

Fixes flutter/flutter#190741

## Pre-Review Checklist

**Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

[^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.
victorsanni pushed a commit to victorsanni/packages that referenced this pull request Sep 9, 2026
…er#12399)

Adds build-time detection of routes that resolve to the same URL pattern. `go_router` matches the first route that fits, so a duplicated path silently makes the later route's page unreachable, and `LaterRoute().go(context)` navigates you to `EarlierRoute`'s page instead. Today nothing surfaces that until you run into the issue at runtime.

Reported as a warning by default, and  new `duplicate_route_paths` builder option accepts `warning` (the default), `error`, and `ignore`, so teams whose duplicates are mistakes can fail the build instead.

**Before**, `go_router_builder`'s own example app built clean despite two duplicate registrations:

```
$ dart run build_runner build
[INFO] Succeeded after 14s with 36 outputs
```

**After**:

```
$ dart run build_runner build
W go_router_builder on lib/all_types.dart:
  Duplicate route path detected: DoubleRoute is declared more than once at "double-route/:requiredDoubleField".
```

That duplicate was real. `DoubleRoute` had been registered twice since flutter#2395 (2022) and `DoubleExtensionRoute` since flutter#9458 (2025). Both were unreachable, and this PR removes them. The only change to the generated output is the dead route entries.

What competes for a URL namespace:

- Sibling routes, with path parameters normalized, so `product/:id` and `product/:productId` are one pattern.
- Routes inside shell routes and `StatefulShellRoute` branches, since those own no path of their own and their children compete with the routes around them.
- Relative routes, which own their path like any other route, so `/home/details/edit` and `/home/edit` stay distinct.
- Routes from separate annotations, since the generated `$appRoutes` collects them into one list. Scope is the library, `part` files included.

**Testing:** five new golden inputs in `test_inputs/` cover sibling duplicates, parameter-name-only differences, `StatefulShellRoute` branches, relative routes, cross-annotation duplicates, and the sound same-class grouping case. The golden harness gained two optional companion files per input, documented in the README: `<name>.dart.options` supplies JSON builder options so each severity is exercised through the real option-parsing path, and `<name>.dart.warnings` asserts logged warnings, with an empty file asserting silence.

Fixes flutter/flutter#190741

## Pre-Review Checklist

**Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

[^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.
Nakiha pushed a commit to Nakiha/VoidPlayer-Flutter that referenced this pull request Sep 28, 2026
flutter/packages@6cb9113...09533b7

2025-08-14 [email protected] Roll Flutter from
524109b to 39100f6 (18 revisions) (flutter/packages#9807)
2025-08-14 [email protected] Add review agent style guidelines to
.gemini/styleguide.md (flutter/packages#9805)
2025-08-13 [email protected] [go_router_builder] Support extension
types (flutter/packages#9458)
2025-08-13 [email protected] Roll Flutter from
3ad3a5b to 524109b (41 revisions) (flutter/packages#9803)

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_builder] Support extension types as route arguments

4 participants