How can we handle deep links in flutter with Get X for go to Custom pages of the application?
546
Do the page routing in your app, when you process the deeplink.
In my apps, I usually use uni_links (https://pub.dev/packages/uni_links) and in my main.dart
, I have something like this:
StreamSubscription<String> _subUniLinks;
@override
initState() {
super.initState();
// universal link setup
initUniLinks();
}
Future<void> initUniLinks() async {
try {
final String initialLink = await getInitialLink();
await processLink(initialLink);
} on PlatformException {
}
_subUniLinks = linkStream.listen(processLink, onError: (err) {});
}
processLink(String link) async {
// parse link and decide what to do:
// - use setState
// - or use Navigator.pushReplacement
// - or whatever mechanism if you have in your app for routing to a page
}
@override
dispose() {
if (_subUniLinks != null) _subUniLinks.cancel();
super.dispose();
}
Comments
-
Huseyn over 1 year
How can we handle deep links in flutter with Get X for go to Custom pages of the application ?
By default, by adding the desired address to the Android Manifest file:
<meta-data android:name="flutter_deeplinking_enabled" android:value="true" /> <intent-filter android:autoVerify="true"> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="http" android:host="flutterbooksample.com" /> <data android:scheme="https" android:host="flutterbooksample.com"/> </intent-filter>
when the application opens, the main page of application will be displayed to us.
I am looking to implement this I can direct the user to any page of the application that is needed. A practical example is to pay on the web page and return to the application. When we return, we should show the user a message about the status of the payment, not direct the user to the first page of the application.
-
Infaz over 2 yearsDid you find a solution for this?
-
Huseyn over 2 yearsUnfortunately no @Infaz
-
Infaz over 2 yearsOk, Thanks for the response
-
Huseyn over 2 yearsHi, @Infaz here is an answer.
-
Infaz over 2 yearsThanks, @Huseyn, I will try this out.
-
-
Mijanur Rahaman about 2 yearswhere this linkStream come from ?