Apply Deep Linking in flutter app to open a specific page in another app or same app i want to know to how implement deep links in flutter or open channel with android native and ios native ? ?


Solution 1: Lena Bru

I think it would be the same as in a normal android app. Deeplinking is a configuration thing rather than code. You need to write some things in your android manifest. Have a look at the firebase manual for deep linking:

Firebase deeplinking manual


Solution 2: Kinjal

You can use firebase dynamic links for deep linking in a flutter. Refer this link for full implement steps and create and receive a link, https://medium.com/better-programming/deep-linking-in-flutter-with-firebase-dynamic-links-8a4b1981e1eb. Here is a sample code for receiving a link inside the app and open a new screen.

class MainWidgetState extends State<MainWidget> {

  @override
  void initState() {
    super.initState();
    this.initDynamicLinks();
  }

  initDynamicLinks(BuildContext context) async {
    await Future.delayed(Duration(seconds: 3));
    var data = await FirebaseDynamicLinks.instance.getInitialLink();
    var deepLink = data?.link;
    final queryParams = deepLink.queryParameters;
    if (queryParams.length > 0) {
      var userName = queryParams['userId'];
      openNewScreen(userName);
    }
    FirebaseDynamicLinks.instance.onLink(onSuccess: (dynamicLink)
    async {
      var deepLink = dynamicLink?.link;
      final queryParams = deepLink.queryParameters;
      if (queryParams.length > 0) {
        var userName = queryParams['userId'];
        openNewScreen(userName);
      }
      debugPrint('DynamicLinks onLink $deepLink');
    }, onError: (e) async {
      debugPrint('DynamicLinks onError $e');
    });
  }

  openNewScreen(String userName){
    Navigator.of(context).pushNamed("routeFormScreen", arguments: {"name": userName});
  }
}