getx
getx copied to clipboard
Android deep link
Of user click a link then app will open and open particular page using get navigator, how is this possible with get navigator. deep linking on Android
Same here
any updates?
Any updates on this? Is it possible/has someone done Android deep linking following the flutter docs and using getmaterialapp / get navigation? or even using the uni_links package? @jonataslaw I know you're busy with getx 5, do you have any reccomendations?
@hanumanjiblog @alejandrogiubel @diego-lipinski-de-castro were any of you able to figure out? and willing to share
I have the following situation happening here:
I followed the deeplink settings for Android and iOs that are described here (except the GoRouter part because I'm using Get):
https://docs.flutter.dev/cookbook/navigation/set-up-app-links https://docs.flutter.dev/cookbook/navigation/set-up-universal-links
The following code works:
return GetMaterialApp( ..... initialRoute: "/", routes: { "/privacy": (context) => const PolicyPrivacyPage(), "/terms": (context) => const TermsPage(), "/support" : (context) => const SupportPage(), "/download" : (context) => const DownloadPage(), }, getPages: [ GetPage(name: "/", page: () => const HomePage()), GetPage(name: "/privacy", page: () => const PolicyPrivacyPage()), GetPage(name: "/terms", page: () => const TermsPage()), GetPage(name: "/support", page: () => const SupportPage()), GetPage(name: "/download", page: () => const DownloadPage()), GetPage( name: '/report', page: () { String? reportId = Get.parameters["id"]; if(reportId!=null) { return LoadReportPage(reportId); }else{ return const HomePage(); } ), ), ], );
In this case, the links must be in the format: www.example.com/report?id=1234
But I need the app to open links in the format www.example.com/report/1234 so i tried the following code according to the Get documentation:
GetPage( name: '/report/:id', page: () { String? reportId = Get.parameters["id"]; if(reportId!=null) { return LoadReportPage(reportId); }else{ return const HomePage(); } ),
But then I'm getting the error above:
The following _TypeError was thrown building _FocusInheritedScope: Null check operator used on a null value
The relevant error-causing widget was:
Directionality Directionality:file:///C:/Users/wantr/AppData/Local/Pub/Cache/hosted/pub.dev/get-4.6.6/lib/get_navigation/src/root/get_material_app.dart:328:12
When the exception was thrown, this was the stack:
#0 ParseRouteTree._parseParams (package:get/get_navigation/src/root/parse_route.dart:173:55)
#1 ParseRouteTree.matchRoute (package:get/get_navigation/src/root/parse_route.dart:64:28)
#2 PageRedirect.needRecheck (package:get/get_navigation/src/routes/route_middleware.dart:258:33)
#3 PageRedirect.page (package:get/get_navigation/src/routes/route_middleware.dart:199:12)
#4 GetMaterialApp.initialRoutesGenerate (package:get/get_navigation/src/root/get_material_app.dart:348:9)
#5 _WidgetsAppState.build.
The following assertion was thrown building _FocusInheritedScope: A GlobalKey was used multiple times inside one widget's child list.
The offending GlobalKey was: [LabeledGlobalKey<NavigatorState>#23677 Key Created by default]
The parent of the widgets with that key was: _FocusInheritedScope
The first child to get instantiated with that key became: Navigator-[LabeledGlobalKey<NavigatorState>#23677 Key Created by default]
dirty
dependencies: [UnmanagedRestorationScope]
state: NavigatorState#48c2d(lifecycle state: initialized)
The second child that was to be instantiated with that key was: _FocusInheritedScope
A GlobalKey can only be specified on one widget at a time in the widget tree.
The relevant error-causing widget was:
Directionality Directionality:file:///C:/Users/wantr/AppData/Local/Pub/Cache/hosted/pub.dev/get-4.6.6/lib/get_navigation/src/root/get_material_app.dart:328:12
When the exception was thrown, this was the stack:
#0 Element._retakeInactiveElement.
Am i doing something wrong? Is there a way to open links in www.example.com/report/1234 format?
I don't know if i can help with something but i edited the code in the file parse_route.dart to print some stuffs:
Map<String, String> _parseParams(String path, PathDecoded routePath) { final params = <String, String>{}; var idx = path.indexOf('?'); if (idx > -1) { path = path.substring(0, idx); final uri = Uri.tryParse(path); if (uri != null) { params.addAll(uri.queryParameters); } } var paramsMatch = routePath.regex.firstMatch(path); print(">>>>>>>>>>> path ${path}"); print(">>>>>>>>>>> routePath.regex ${routePath.regex}"); print(">>>>>>>>>>> routePath.keys ${routePath.keys}"); print(">>>>>>>>>>> paramsMatch ${paramsMatch}"); for (var i = 0; i < routePath.keys.length; i++) { var param = Uri.decodeQueryComponent(paramsMatch![i + 1]!); params[routePath.keys[i]!] = param; } return params; }
The Web output:
>>>>>>>>>>> path /report/KfcegKeUB6KrfJvo4akA
>>>>>>>>>>> routePath.regex RegExp/^/report/(?:([\w%+-._~!$&'()*,;=:@]+))/?$/
>>>>>>>>>>> routePath.keys [id]
>>>>>>>>>>> paramsMatch Instance of '_MatchImplementation'
The Android output:
I/flutter (14536): >>>>>>>>>>> path https://example.com.br/report/KfcegKeUB6KrfJvo4akA
I/flutter (14536): >>>>>>>>>>> routePath.regex RegExp: pattern=^/report/(?:([\w%+-._~!$&'()*,;=:@]+))/?$ flags=
I/flutter (14536): >>>>>>>>>>> routePath.keys [id]
I/flutter (14536): >>>>>>>>>>> **paramsMatch null**
It only works on web
@wantroba. I am also getting the exact same issue. Have you found any workaround yet?
@wantroba. I am also getting the exact same issue. Have you found any workaround yet?
The only way that worked for me was to use the links in the format www.example.com/page?id=1234.
Thanks. This workaround gives a good go for me.
What if the link cannot be changed? Are there some other ways to make it work?
What if the link cannot be changed? Are there some other ways to make it work?
With Getx current version(4.6.6) path variable is not going to work. You have to wait for an update of Getx(Probably 5.0.0). Or you can use other routing system(like goRoute) if you wish to not using getx's named route.
When i am using Getx and uni_links I am getting an Error on LabledGlobelKey<NavigatorKey>. Need Help. Thanks in advance App Opened Normally (Icon Tap) Working App in Background and Link Tap Working App Terminated, Opened Normally then it is working App Terminated, Opened Tapping Link then it is not working. Then it is giving error.
I've submitted a PR (#3067) that aims to address the problem you've encountered.
have someone resloved this issue
When i am using Getx I am getting an Error on LabledGlobelKey. Need Help. Thanks in advance i can't used any package just like uni_link because getx handle it byself App Opened Normally (Icon Tap) Working App in Background and Link Tap Working App Terminated, Opened Normally then it is working App Terminated, Opened Tapping Link then it is not working. Then it is giving error.