Stacked-Org/stacked

[bug]: Deep Nested Routing Duplicate Functions Generated

Opened this issue · 2 comments

Describe the bug

When adding the same route as a child to different sections for deep nesting I receive the below error once generating.

Try renaming one of the declarations.```

### What operating system do you use?

macOS

### Information about the installed tooling

[✓] Flutter (Channel stable, 3.24.0, on macOS 14.6.1 23G93 darwin-arm64, locale en-US)
    • Flutter version 3.24.0 on channel stable at /Users/rickeylee/Desktop/dev/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 80c2e84975 (4 weeks ago), 2024-07-30 23:06:49 +0700
    • Engine revision b8800d88be
    • Dart version 3.5.0
    • DevTools version 2.37.2

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/rickeylee/Library/Android/sdk
    • Platform android-34-ext8, build-tools 34.0.0
    • ANDROID_HOME = /Users/rickeylee/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    • All Android licenses accepted.

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

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.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.7+0-17.0.7b1000.6-10550314)

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

[✓] Connected device (6 available)            
    • SM F926U (mobile)                              • RFCR802EMHY               • android-arm64  • Android 13 (API 33)
    • iPhone 15 Pro Max (mobile)                     • 00008130-00125D660CFA001C • ios            • iOS 17.5.1 21F90
    • iPad Pro (12.9-inch) (5th generation) (mobile) • 00008101-000C1CE60E88801E • ios            • iOS 17.6.1 21G93
    • macOS (desktop)                                • macos                     • darwin-arm64   • macOS 14.6.1 23G93 darwin-arm64
    • Mac Designed for iPad (desktop)                • mac-designed-for-ipad     • darwin         • macOS 14.6.1 23G93 darwin-arm64
    • Chrome (web)                                   • chrome                    • web-javascript • Google Chrome 128.0.6613.84
    ! Error: Browsing on the local area network for rickey’s Apple Watch. Ensure the device is unlocked and discoverable via Bluetooth. (code -27)
    ! Error: Browsing on the local area network for iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as
      this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
    • All expected network resources are available.

• No issues found!

### Steps to reproduce the issue

@StackedApp(
  routes: [
    CustomRoute(page: StartupView, initial: true, path: '/loading'),
    CustomRoute(
      path: '/',
      page: TabBarView,
      // guards: [AuthGuard],
      children: [
        CustomRoute(page: HomeRoute, path: 'home', initial: true, children: [
          CustomRoute(page: HomeView, initial: true, usesPathAsKey: true),
          CustomRoute(
            page: ProfileRoute,
            path: 'profile/:id',
            children: [
              CustomRoute(
                page: ProfileView,
                initial: true,
              ),
              CustomRoute(
                page: EditProfileView,
                path: 'edit',
              ),
              CustomRoute(
                page: PostRoute,
                path: 'post/:id',
                children: [
                  CustomRoute(
                    page: PostFullViewView,
                    initial: true,
                  ),
                  CustomRoute(
                    page: ReactionsListView,
                    path: 'reactions',
                    fullscreenDialog: true,
                  ),
                  CustomRoute(
                    page: FullScreenCarouselView,
                    path: 'files',
                  ),
                ],
              ),
              CustomRoute(
                page: MessageRoute,
                path: ':id',
                children: [
                  CustomRoute(
                    page: MessagesView,
                    initial: true,
                  ),
                  CustomRoute(
                    page: ChatDetailRoute,
                    path: 'details',
                    children: [
                      CustomRoute(
                        page: ChatDetailsView,
                        initial: true,
                      ),
                      CustomRoute(
                        page: AddMembersView,
                        path: 'addMembers',
                      ),
                      CustomRoute(
                        page: ChatMediaView,
                        path: 'media',
                      ),
                      CustomRoute(
                        page: MemberListView,
                        path: 'members',
                      ),
                      CustomRoute(
                        page: MemberRequestView,
                        path: 'request',
                      ),
                      CustomRoute(
                        page: PinnedMessageRoute,
                        path: 'pinned',
                        children: [
                          CustomRoute(
                            page: PinnedMessagesView,
                            initial: true,
                          ),
                        ],
                      ),
                    ],
                  ),
                  CustomRoute(
                    page: LobbyViewView,
                    path: 'lobby/:id',
                  ),
                  CustomRoute(
                    page: VideoCallView,
                    path: 'call/video/:id',
                  ),
                  CustomRoute(
                    page: PostRoute,
                    path: 'post/:id',
                    children: [
                      CustomRoute(
                        page: PostFullViewView,
                        initial: true,
                      ),
                      CustomRoute(
                        page: ReactionsListView,
                        path: 'reactions',
                        fullscreenDialog: true,
                      ),
                      CustomRoute(
                        page: FullScreenCarouselView,
                        path: 'files',
                      ),
                    ],
                  ),
                  // post,
                ],
              ),
              // post,
              // chat,
            ],
          ),
          CustomRoute(
            page: MessageRoute,
            path: ':id',
            children: [
              CustomRoute(
                page: MessagesView,
                initial: true,
              ),
              CustomRoute(
                page: ChatDetailRoute,
                path: 'details',
                children: [
                  CustomRoute(
                    page: ChatDetailsView,
                    initial: true,
                  ),
                  CustomRoute(
                    page: AddMembersView,
                    path: 'addMembers',
                  ),
                  CustomRoute(
                    page: ChatMediaView,
                    path: 'media',
                  ),
                  CustomRoute(
                    page: MemberListView,
                    path: 'members',
                  ),
                  CustomRoute(
                    page: MemberRequestView,
                    path: 'request',
                  ),
                  CustomRoute(
                    page: PinnedMessageRoute,
                    path: 'pinned',
                    children: [
                      CustomRoute(page: PinnedMessagesView, initial: true),
                    ],
                  ),
                ],
              ),
              CustomRoute(
                page: LobbyViewView,
                path: 'lobby/:id',
              ),
              CustomRoute(
                page: VideoCallView,
                path: 'call/video/:id',
              ),
              CustomRoute(
                page: PostRoute,
                path: 'post/:id',
                children: [
                  CustomRoute(page: PostFullViewView, initial: true),
                  CustomRoute(
                    page: ReactionsListView,
                    path: 'reactions',
                    fullscreenDialog: true,
                  ),
                  CustomRoute(
                    page: FullScreenCarouselView,
                    path: 'files',
                  ),
                ],
              ),
              // post,
            ],
          ),
          CustomRoute(
            page: PostRoute,
            path: 'post/:id',
            children: [
              CustomRoute(page: PostFullViewView, initial: true),
              CustomRoute(
                page: ReactionsListView,
                path: 'reactions',
                fullscreenDialog: true,
              ),
              CustomRoute(page: FullScreenCarouselView, path: 'files'),
            ],
          ),
          // profile,
          // chat,
          // post,
          CustomRoute(page: PrivacyView),
        ]),
        CustomRoute(page: ChatView, path: 'chats'),
        CustomRoute(page: LivestreamsView, path: 'livestreams'),
        CustomRoute(page: NotificationView, path: 'notifications'),
        CustomRoute(page: SearchView, path: 'search?query=String'),
      ],
    ),

    CustomRoute(page: BlockedListView),
    CustomRoute(page: BookmarksView),
    CustomRoute(page: CameraViewView),

    CustomRoute(page: ChatSearchView),
    CustomRoute(page: CommunitiesView),
    CustomRoute(page: CreateChatView),
    CustomRoute(page: CreatePostView),
    CustomRoute(page: CreateStoryView),
    CustomRoute(page: LivestreamParticipantViewView),
    CustomRoute(page: LivestreamViewView),

    CustomRoute(page: LoginView),

    CustomRoute(page: SettingsView),
    CustomRoute(page: SignupView),
    CustomRoute(page: StoryViewView),
    CustomRoute(page: VerificationHomeView),

// @stacked-route

    CustomRoute(page: UnknownView, path: '/404'),

    /// When none of the above routes match, redirect to UnknownView
    RedirectRoute(path: '*', redirectTo: '/404'),
  ],
  dependencies: [
    LazySingleton(classType: BottomSheetService),
    LazySingleton(classType: DialogService),
    LazySingleton(classType: RouterService),
    // @stacked-service
  ],
  bottomsheets: [
    StackedBottomsheet(classType: NoticeSheet),
    // @stacked-bottom-sheet
  ],
  dialogs: [
    StackedDialog(classType: InfoAlertDialog),
    // @stacked-dialog
  ],
)
class App {}


### Expected behavior

_No response_

### Screenshots

_No response_

### Additional Context

_No response_

We had a similar issue like this recently.

Turned out their setup wasn't correct.

Please read through this and check if it solves your problem.

@FilledStacks It's not the same everything is correct. It's the extension functions for the router. Once I manually remove them I can run the app. Is there a way to stop them from being generated?