New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
go_router is catching app links twice on Android #147848
Comments
Hi @ishchhabra
|
@huycozy While the two seem similar, they are not exactly the same. The issue you mentioned talks about the |
Your sample code has a minor issue (typo?) on Once I updated it, I got another error below: I/flutter (15789): /applinks route trigerred
════════ Exception caught by foundation library ════════════════════════════════
The following assertion was thrown while dispatching notifications for GoRouteInformationProvider:
A redirect-only route must redirect to location different from itself.
The offending route: GoRoute#a104f(name: null, path: "/applink", Redirect Only)
'package:go_router/src/parser.dart':
Failed assertion: line 114 pos 18: '!matchList.last.route.redirectOnly' Then I continued updating the route declaration as: final _router = GoRouter(
routes: [
GoRoute(
path: '/',
builder: (context, state) => const MyHomePage(title: 'Flutter Demo Home Page'),
),
GoRoute(
path: '/applink',
builder: (context, state) => const MyHomePage(title: 'App Link'),
),
],
redirect: (context, state) {
if (state.matchedLocation == '/applink') {
print("/applinks route trigerred");
return '/applink';
}
return null;
},
); Now I can see the log adb shell am start -a android.intent.action.VIEW "http://10.0.2.2:8020/applink" With this result, this is similar to #137037, right? Please retry with this updated sample code and confirm. If your sample code needs to persist as the original, please update it to pass the error above. Thanks! |
My bad, while trying to extract the minimal code from the application where I encountered this, I made some mistakes. I have updated the code. It is similar to the route declaration you mentioned above, but rather than using the global redirect, I added redirect only to the specific route. I also tried the route declaration you mentioned, but in both the cases, i did not see the console print twice on |
Well, I pulled your latest change on your sample repo and ran it. I see the console printed only one time as expected (in both cases). I checked this on Android 11 emulator as yours (I see it from your flutter doctor ouput). DemoScreen.Recording.2024-05-08.at.12.36.40.mp4Please take a look at my demo to see if there are any different steps. |
That is weird. With the code on the sample repo, following is what I see: windows_recording.mp4 |
The only different step I can observe between my and your demo is that: you triggered deep link when app was in foreground whilst I did it when app in background. I tried the same steps as yours but only one log is printed (expected). Could you check |
The |
Thanks for the update. I see it's already the latest package version (same to me). You can test it without using Snippet code of route without using go_routerreturn MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
// routerConfig: _router,
onGenerateRoute: (settings) {
if (settings.name == '/applink') {
print("/applink route triggered");
return MaterialPageRoute(builder: (context) {
return const MyHomePage(title: 'applink');
});
}
return MaterialPageRoute(builder: (context) {
return const MyHomePage(title: 'Flutter Demo Home Page');
});
},
); |
Just tried with the code snippet you provided. The bug also exists without using |
Strangely, it only prints once with that same code (without go_router) on my end. I wonder if there is problem with device/emulator. Could you try on another one? Also, what is your Python version? (I'm using |
I have exactly the same issue. |
What package does this bug report belong to?
go_router
What target platforms are you seeing this bug on?
Android
Have you already upgraded your packages?
Yes
Dependency versions
pubspec.lock
Steps to reproduce
andorid.intent.action.VIEW
with link BExpected results
When link B redirects the user to link A, the deep link should be caught once.
Actual results
The deep link gets caught twice
Code sample
Code sample
https://github.com/ishchhabra/go_router_applink_bug_app
Screenshots or Videos
No response
Logs
No response
Flutter Doctor output
Doctor output
The text was updated successfully, but these errors were encountered: