Skip to content
This repository has been archived by the owner on Feb 25, 2022. It is now read-only.

route name lookup seems to be case sensitive #132

Closed
pryshrm opened this issue Nov 4, 2021 · 5 comments
Closed

route name lookup seems to be case sensitive #132

pryshrm opened this issue Nov 4, 2021 · 5 comments
Labels
bug Something isn't working fix awaiting confirmation

Comments

@pryshrm
Copy link

pryshrm commented Nov 4, 2021

Given the router configuration below,

This works:
GoRouter.of(context!).pushNamed(**'note1'**, params: {'noteid': id!.toString()},);

and This does not work :
GoRouter.of(context!).goNamed(**'tab1AndNote1'**, params: {'noteid': id!.toString()},);

Exception: unknown route name: tab1AndNote1

So, my question is can the name given to the uppermost path segment ( here, tab1AndNote1 ) ever be used as a name?

I have the following go router configuration:

final _router = GoRouter(
    routes: [
      GoRoute(
        name: 'root',
        path: '/',
        pageBuilder: (context, state) {
          return MaterialPage<void>(
            key: state.pageKey,
            child: const MainAppScreen(),
          );
        },
      ),
      GoRoute(
        name: 'tab1AndNote1',
        path: '/tab1',
        pageBuilder: (context, state) {
          return MaterialPage<void>(
            key: state.pageKey,
            child: const MainAppScreen(),
          );
        },
        routes: [
          GoRoute(
            name: 'note1',
            path: 'note1/:noteid',
            pageBuilder: (context, state) {
              int noteid = int.tryParse(state.params['noteid'] ?? "0") ?? 0;
              return MaterialPage<void>(
                key: state.pageKey,
                child: NoteDetailScreen(noteid: noteid),
              );
            },
          ),
        ],
      ),
    ],
  );
@csells
Copy link
Owner

csells commented Nov 4, 2021

@pryshrm can you post a complete but minimal repro project that demonstrates this issue? The behavior you're asking for works in all of my testing (a lot). I suspect something else is causing the issue.

@pryshrm
Copy link
Author

pryshrm commented Nov 5, 2021

I found the issue. In the GoRouter configuration (posted above), I have specified the name as 'tab1AndNote1' (notice the casing). Although, when calling goNamed(), I am using the same name with the exact same case but that doesn't work.
However, when I changed the name to all lower case, it worked. i.e. goNamed('tab1andnote1', ...) is working....even though, in the configuration, the name is tab1AndNote1.

I found this out after I set debugLogDiagnostics: true. It printed out the name for the route as tab1andnote1 (all lower case).

So, the question now is, is this expected?

@csells
Copy link
Owner

csells commented Nov 5, 2021

Ah. Name lookup should be case insensitive. I'll take a look.

@csells csells added bug Something isn't working and removed waiting on customer input labels Nov 5, 2021
@csells csells changed the title Which name to use while using push/goNamed route name lookup seems to be case sensitive Nov 5, 2021
@pryshrm
Copy link
Author

pryshrm commented Nov 6, 2021

As of now, it is neither case sensitive nor case insensitive because, as of now, route name tab1AndNote1 is matched only with goNamed('tab1andnote1').

@csells
Copy link
Owner

csells commented Nov 7, 2021

this should be fixed in v2.2.3. @pryshrm can you confirm?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working fix awaiting confirmation
Projects
None yet
Development

No branches or pull requests

2 participants