Docs

Link Creation

Generate smart links programmatically in your Flutter app

Use generateLink to create a smart link with optional metadata, tracking, and redirects. It returns the link URL as a String:

Dart
import 'package:flutter/foundation.dart';
import 'package:grovs_flutter_plugin/grovs.dart';
import 'package:grovs_flutter_plugin/models/grovs_link.dart';
 
final grovs = Grovs();
 
Future<String> createShareLink() async {
  try {
    final link = await grovs.generateLink(
      GenerateLinkParams(
        title: 'Check out this product',
        subtitle: 'Limited time offer',
        imageURL: 'https://example.com/image.jpg',
        data: {
          'screen': 'product',
          'productId': '12345',
        },
        tags: ['promotion', 'share'],
        tracking: TrackingParams(
          utmCampaign: 'spring_sale',
          utmSource: 'in_app',
          utmMedium: 'share_button',
        ),
      ),
    );
 
    debugPrint('Generated: $link');
    return link;
  } on GrovsException catch (e) {
    debugPrint('Error: ${e.message} (${e.code})');
    rethrow;
  }
}

Link generation needs the SDK to be configured, enabled, and authenticated. A failure surfaces as a GrovsException whose code is GENERATION_ERROR; the message carries the native error text on Android and a generic message on iOS.

Parameters

ParameterTypeDescription
titleStringLink preview title (required)
subtitleString?Link preview subtitle
imageURLString?Link preview image URL
dataMap<String, dynamic>?Custom payload delivered on deep link open
tagsList<String>?Tags for filtering and analytics
customRedirectsCustomRedirects?Override the default redirect per platform. See Custom redirects
showPreviewIosbool?Show the link preview page on iOS. null uses the project default
showPreviewAndroidbool?Show the link preview page on Android. null uses the project default
copyToClipboardIosbool?Copy the link to the clipboard from the preview page on iOS, for clipboard-assisted deferred deep linking. null inherits the project setting
copyToClipboardAndroidbool?Same, for Android. null inherits the project setting
trackingTrackingParams?UTM campaign, source, and medium

copyToClipboardIos and copyToClipboardAndroid only take effect when the preview page is shown for that platform. Passing false is an explicit override, not the same as omitting the parameter. The project-level setting and what the visitor sees are described in Copy to Clipboard.

On Android, payload values in data that are strings, numbers, booleans, or otherwise serializable are passed through as they are; anything else is converted with toString(). On iOS the map is passed through unchanged.

Custom redirects

Override where a link sends users on each platform:

Dart
final link = await grovs.generateLink(
  GenerateLinkParams(
    title: 'Special offer',
    data: {'promoId': 'summer25'},
    customRedirects: CustomRedirects(
      ios: CustomLinkRedirect(url: 'https://example.com/ios-promo'),
      android: CustomLinkRedirect(url: 'https://example.com/android-promo'),
      desktop: CustomLinkRedirect(
        url: 'https://example.com/desktop-promo',
        openAppIfInstalled: false,
      ),
    ),
  ),
);

When openAppIfInstalled is true (the default), the app opens if it is installed and the redirect URL is used otherwise. When false, the redirect URL is always used.

Launch the platform share sheet once the link is generated, for example with the share_plus package:

Dart
import 'package:share_plus/share_plus.dart';
 
final link = await grovs.generateLink(
  GenerateLinkParams(title: 'Share this', data: {'itemId': 'abc'}),
);
await Share.share(link);

Next steps

Edit this page on GitHubLast updated 2026-10-07