Reputation: 61
I'm trying to do deeplinking in one of my Flutter projects using GoRouter. The link I'm trying to open has the following format:
https://url/confirm?token=token&tokenId=tokenId
The route I have defined for this type of link is the following:
GoRoute(
path: '/confirm?token=:token&tokenId=:tokenId',
builder: (_, __) => AccountConfirmationScreen(
token: __.queryParameters['token'] ?? '',
tokenId: __.queryParameters['tokenId'] ?? '',
),
),
The app gets opened when I tap the link on my phone but it does not navigate to the intended screen, I get navigated to a blank screen and I get an error saying GoRouter could not find a route for that url. Does anybody have any idea how that route should look? I feel like I'm doing something wrong when declaring it but I can't figure it out.
Thanks a lot in advanced!
Edit: added screenshot for reference
Edit2: I've changed the route to this to match the expected route
GoRoute(
path:
'/confirm?token=5b85ad8ff63a53f1033c13389246b5b1b6502b634c305cc6d431a2688778e0e93d9d1875c1f5dbaef41c5a586033f5c751c8e17c61105b85d26531a16168&tokenld=64a9d5d5d41077baa0179d1',
builder: (_, __) => AccountConfirmationScreen(
token: __.queryParameters['token'] ?? '',
tokenId: __.queryParameters['tokenId'] ?? '',
),
),
And I still get the same problem, so maybe the problem is more complex. Hope this might help.
Upvotes: 2
Views: 2640
Reputation: 321
You could try this instead:
GoRoute(
path: '/confirm',
builder: (_, __) => AccountConfirmationScreen(
token: __.queryParameters['token'] ?? '',
tokenId: __.queryParameters['tokenId'] ?? '',
),
),
and to navigate to that screen:
context.go("confirm?token=${token}&tokenId=${tokenId}",);
Upvotes: 0