Link Creation
Generate smart links programmatically in your Flutter app
Generating a link
Use generateLink to create a smart link with optional metadata, tracking, and redirects:
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',
),
),
);
print('Generated: $link');
return link;
} on GrovsException catch (e) {
print('Error: ${e.message}');
rethrow;
}
}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),
),
),
);Share dialog
Launch the platform share sheet after generating a link:
Dart
import 'package:share_plus/share_plus.dart';
final link = await grovs.generateLink(
GenerateLinkParams(title: 'Share this', data: {'itemId': 'abc'}),
);
Share.share(link);Parameters
| Parameter | Type | Description |
|---|---|---|
title | String | Link preview title (required) |
subtitle | String? | Link preview subtitle |
imageURL | String? | Link preview image URL |
data | Map<String, dynamic>? | Custom payload delivered on deep link open |
tags | List<String>? | Tags for filtering and analytics |
tracking | TrackingParams? | UTM tracking parameters |
customRedirects | CustomRedirects? | Override default redirect behavior per platform |
showPreviewIos | bool? | Show link preview on iOS (uses dashboard default if null) |
showPreviewAndroid | bool? | Show link preview on Android (uses dashboard default if null) |