Skip to content

[go_router_builder]: Since go_router: 14.2.9, generated locations are different for route paths with or without slash #156382

Open
flutter/packages
#13718

Description

@CaoGiaHieu-dev

Steps to reproduce

Define a route with child route . all child route contains '/' in their path
ex: "/abc", "/edg"

Expected results

.g.dart file cannot generate correct path for child

Actual results

generate correct path

Code sample

Code sample
TypedGoRoute<ProfileRoute>(
          path: "/profile",
          routes: [
            TypedGoRoute<SettingRoute>(
              path: "/setting",
              ....      

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.24.3, on macOS 14.5 23F79 darwin-arm64, locale vi-VN)
    • Flutter version 3.24.3 on channel stable at /Users/hieucg/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2663184aa7 (4 weeks ago), 2024-09-11 16:27:48 -0500
    • Engine revision 36335019a8
    • Dart version 3.5.3
    • DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at /Users/hieucg/Library/Android/sdk
    • Platform android-35, build-tools 35.0.0
    • ANDROID_HOME = /Users/hieucg/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16A242d
    • CocoaPods version 1.15.2

[✓] Android Studio (version 2024.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)

[✓] VS Code (version 1.94.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.98.0

Activity

  1. added
    in triagePresently being triaged by the triage team
    on Oct 8, 2024
  2. huycozy commented on Oct 8, 2024

    @huycozy
    Member

    Hi @CaoGiaHieu-dev
    I am using package's simple_example with modified FamilyRoute path as below but I see the generated path is expected:

    @TypedGoRoute<HomeRoute>(
      path: '/',
      name: 'Home',
      routes: <TypedGoRoute<GoRouteData>>[
        TypedGoRoute<FamilyRoute>(path: '/family/:familyId')
      ],
    )
    RouteBase get $homeRoute => GoRouteData.$route(
          path: '/',
          name: 'Home',
          factory: $HomeRouteExtension._fromState,
          routes: [
            GoRouteData.$route(
              path: '/family/:familyId',
              factory: $FamilyRouteExtension._fromState,
            ),
          ],
        );

    Please also try the same example and confirm this. If the issue only appears on your code, please provide a minimal sample code. Thanks!

  3. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Oct 8, 2024
  4. CaoGiaHieu-dev commented on Oct 8, 2024

    @CaoGiaHieu-dev
    Author

    @huycozy thank you for your reply , it still happen on my code
    Here my example
    Router path

    static const profile = '/profile';
    static const setting = '/setting'; // this getting error

    Router define

    @TypedStatefulShellRoute<DashboardRoute>(
      branches: [
        TypedStatefulShellBranch(
          routes: [
            TypedGoRoute<ProfileRoute>(
              path: Routes.profile,
              routes: [
                TypedGoRoute<SettingRoute>(
                  path: Routes.setting,
                ),
              ],
            ),
          ],
        ),
      ],
    )

    Result when using setting
    Ảnh màn hình 2024-10-08 lúc 18 01 24

    Result when using /setting
    Ảnh màn hình 2024-10-08 lúc 17 59 59

  5. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Oct 8, 2024
  6. huycozy commented on Oct 9, 2024

    @huycozy
    Member

    Thanks for your update. I see you are using StatefulShellRoute instead and it seems your routes are nested.

    What is the expected result? Do you mean the location on setting route should be /profile/setting? (the actual and expected results in the original comment is reversed btw)

    Can you please leverage package's stateful_shell_route_example and share a complete updated sample code here so that others can quickly review and address this further? Thanks!

    Please provide the info in text/code blocks format instead of a screenshot for better readability and investigation, see avoid posting screenshots of text.

  7. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Oct 9, 2024
  8. CaoGiaHieu-dev commented on Oct 9, 2024

    @CaoGiaHieu-dev
    Author

    @huycozy https://github.com/CaoGiaHieu-dev/go_route_issue please check this
    Expect result :want use go "setting" path with or without "/"

  9. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Oct 9, 2024
  10. huycozy commented on Oct 9, 2024

    @huycozy
    Member

    Thanks for providing a complete sample code. I can reproduce the issue now. This seems to relate to 14.2.9 change: Relaxes route path requirements. Both root and child routes can now start with or without '/'.

  11. changed the title [-][go_router_builder] : Cannot work with Go router 14.2.9 +[/-] [+][go_router_builder]: Since `go_router: 14.2.9`, generated locations are different for route paths with or without splash[/+] on Oct 9, 2024
  12. added
    packageflutter/packages repository. See also p: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Oct 9, 2024
  13. 1 remaining item

  14. cedvdb commented on Oct 10, 2024

    @cedvdb
    Contributor

    go_router_builder hasn't been modified in that regard. It may needs to be upgraded as well if support for child paths starting with / is needed in go_router_builder too. Currently the builder may not support this and the workaround is to not use that kind of path with go_router_builder.

    This is just a guess, without looking into it.

  15. changed the title [-][go_router_builder]: Since `go_router: 14.2.9`, generated locations are different for route paths with or without splash[/-] [+][go_router_builder]: Since `go_router: 14.2.9`, generated locations are different for route paths with or without slash[/+] on Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listfound in release: 3.24Found to occur in 3.24has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: go_routerThe go_router packagep: go_router_builderThe go_router_builder packagepackageflutter/packages repository. See also p: labels.team-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions