Link Creation
Generate smart links programmatically in your Flutter app
Generating a link
Use generateLink to create a smart link. All parameters except the callback are optional:
Dart
import 'package:grovs_flutter_plugin/grovs.dart';
import 'package:grovs_flutter_plugin/models/grovs_link.dart';
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',
payload: {
'screen': 'product',
'productId': '12345',
},
tags: ['promotion', 'share'],
tracking: TrackingParams(
utmCampaign: 'spring_sale',
utmSource: 'in_app',
utmMedium: 'share_button',
),
customRedirects: {
'ios': 'https://custom-ios-redirect.com',
'android': 'https://custom-android-redirect.com',
'desktop': 'https://custom-desktop-redirect.com',
},
),
);
print('Generated: $link');
return link;
} on GrovsException catch (e) {
print('Error: ${e.message}');
rethrow;
}
}Parameters
| Parameter | Type | Description |
|---|---|---|
title | String? | Link preview title |
subtitle | String? | Link preview subtitle |
imageUrl | String? | Link preview image URL |
payload | Map<String, dynamic>? | Custom data delivered on deep link open |
tags | List<String>? | Tags for filtering and analytics |
tracking | TrackingParams? | UTM tracking parameters |
customRedirects | Map<String, String>? | Override default redirect URLs per platform |