2

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.

Huseyn
  • 372
  • 1
  • 7
  • 20

1 Answers1

2

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();
}


Didier Prophete
  • 1,834
  • 1
  • 12
  • 11