Firebase Dynamic Link With Dynamic Parameters?

I'm trying to add a dynamic parameter to my dynamic link. For example, if I have a link as added to the firebase console. I want that id=1 should be dynamic i.e using the same link I could pass on this for different ids rather than creating links for each id and checking each time into the code to redirect to the Flutter screen from getRoute() mentioned below.

Can anyone suggest some way to achieve this?

// Flutter imports:
import 'package:flutter/material.dart';

// Package imports:
import 'package:firebase_dynamic_links/firebase_dynamic_links.dart';

// Project imports:
import 'package:xyz/src/ui/home_screen.dart';
import 'package:xyz/src/ui/promo_screen.dart';

class DynamicLinksService {

  static Future<Widget> initDynamicLinks() async {
    final PendingDynamicLinkData? data = await FirebaseDynamicLinks.instance.getInitialLink();

    if (data != null){
      return getRoute(;
        onSuccess: (PendingDynamicLinkData? dynamicLink) async {
          return getRoute(dynamicLink!.link);
    }, onError: (OnLinkErrorException e) async {
      return e.message;
    return HomeScreen();
  static Widget getRoute(deepLink){
    if (deepLink.toString().isEmpty) {
      return HomeScreen();
    if (deepLink.path == "/promo") {
      final id = deepLink.queryParameters["id"];
      if (id!= null) {
        return PromoScreen(id: id);
    return HomeScreen();


Ajinkya Taranekar



I can share with you the code I use to create dynamic links with a parameter:

class DynamicLinksService {
  static Future<Uri> getGroupDynamicLink(
      BuildContext context, String id) async {
    final DynamicLinkParameters parameters = DynamicLinkParameters(
      uriPrefix: '',
      link: Uri.parse(
      dynamicLinkParametersOptions: DynamicLinkParametersOptions(
          shortDynamicLinkPathLength: ShortDynamicLinkPathLength.unguessable),
      androidParameters: AndroidParameters(
        packageName: 'com.my_page',
        minimumVersion: 0,
      iosParameters: IosParameters(
        bundleId: 'com.my_page',
        minimumVersion: '0',
        appStoreId: '122343564',
      socialMetaTagParameters: SocialMetaTagParameters(
          title: AppLocalization.of(context).getMessage('join_info_group'),
          description: group.title,
          imageUrl: Uri.parse(group.image)),

    final link = await parameters.buildUrl();
    final ShortDynamicLink shortenedLink =
        await DynamicLinkParameters.shortenUrl(
          shortDynamicLinkPathLength: ShortDynamicLinkPathLength.unguessable),

    final Uri dynamicUrl = shortenedLink.shortUrl;

    return dynamicUrl;

Just change the values to your project values and data.