Home > Mobile >  How to get parameter value from link in flutter?
How to get parameter value from link in flutter?

Time:07-01

I am using Firebase dynamic links and I save it to a deepLink variable and pass it to the next page. Tell me, how can I get the code and pageName parameters from the link so that I can use them in the future?

url

https://.........app?pageName=emailActivationPage&code=7075

code

await Firebase.initializeApp();

  final PendingDynamicLinkData? initialLink =
      await FirebaseDynamicLinks.instance.getInitialLink();

if (widget.initialLink != null) {
      final Uri deepLink = widget.initialLink!.link;
      routeCubit.toForgotPasswordPage(deepLink.path, true);
    } else {
      routeCubit.toPhoneNumberPage();
      }

CodePudding user response:

You can access the data through the queryParameter property. It also should be a good idea to check beforehand if the key is given in the Map

if(deepLink.queryParameters.containsKey('code')){
final code = deepLink.queryParameters['code'];
}
  • Related