Comments (13)
Hi @ishchhabra
Perhaps this is similar to #137037 even though the case is not really the same (you can also check it to see if it assembles your case). To confirm this, could you clarify:
- Does the issue occur if you start link A directly but not via link B?
from flutter.
@huycozy While the two seem similar, they are not exactly the same. The issue you mentioned talks about the builder
being triggered twice, whereas this issue talks about even the redirect
(which is mentioned as the workaround in that issue) being triggered twice. No, the issue does not occur if I start the link A directly - in that case, the redirect is only triggered once.
from flutter.
Your sample code has a minor issue (typo?) on /applinks
route path, it should be /applink
to sync with path data on AndroidManifest; otherwise no routes for location
error will occur.
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 applinks route trigerred
is printed twice from the output console. But the issue also occurs if I trigger direct link with:
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!
from flutter.
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 adb shell am start -a android.intent.action.VIEW "http://10.0.2.2:8020/applink"
but only on adb shell am start -a android.intent.action.VIEW "http://10.0.2.2:8020"
. Are there OS or any other differences that could be relevant here as well?
from flutter.
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).
Demo
Screen.Recording.2024-05-08.at.12.36.40.mp4
Please take a look at my demo to see if there are any different steps.
from flutter.
That is weird. With the code on the sample repo, following is what I see:
windows_recording.mp4
from flutter.
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 go_router
version which is fetched on your end? You can find it on pubspec.lock
file. If you can try checking this without go_router
package to narrow the scope of investigation, it would be appreciated.
from flutter.
go_router:
dependency: "direct main"
description:
name: go_router
sha256: "9e0f7d1a3e7dc5010903e330fbc5497872c4c3cf6626381d69083cc1d5113c1e"
url: "https://pub.dev"
source: hosted
version: "14.0.2"
The go_router
version being pulled in 14.0.2
. Could you elaborate on how I would check this without the go_router
package? I'm not sure where the handler code (print statement) would go in case I'm not using go_router
.
from flutter.
Thanks for the update. I see it's already the latest package version (same to me). You can test it without using go_router
package like this:
Snippet code of route without using go_router
return 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');
});
},
);
from flutter.
Just tried with the code snippet you provided. The bug also exists without using go_router
from flutter.
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 Python 3.11.7
). Could you check if Python server sends twice?
from flutter.
I have exactly the same issue.
from flutter.
Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now.
If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones.
Thanks for your contribution.
from flutter.
Related Issues (20)
- Weird transition animation when swipe back on Android with CupertinoPageTransitionsBuilder
- [Material3] TabBar indicator stretch effect behaving weirdly with long tabs
- Thanks for your input @moffatman. HOT 1
- flutter_engine_group_performance failing consistently on mokey
- mac-10 & mac-26 lost external connection phone device. HOT 1
- mac-29 lost external connection phone device. HOT 1
- linux-49 is dead. HOT 1
- Golden tests failed to run on the 3.23 beta release HOT 8
- When running Web Renderer HTML chips label not disabled color
- Network issue on macOS chromium bots HOT 2
- [go_router_builder] Compile-time exception when using not null `List`
- mac-14 lost external connection phone device. HOT 1
- Unable to build application if a plugin depends on an .AAR
- Support `contrastLevel` in `ColorScheme.fromSeed`
- ICU-to-flutter roller has been failing for multiple weeks HOT 1
- [Web] TextField loses focus when tapping outside despite using TextFieldTapRegion HOT 2
- mac-24 lost external connection phone device. HOT 1
- [flutter_tools] broken pipe during `flutter debug_adapter`
- [Impeller] column of material renders slight gap when there should be none HOT 13
- [Impeller] LinearGradient no longer fills in all the way HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter.