Skip to main content

🦋 Generate Dynamic Links in Flutter

This guide covers how to create a Dynamic Link directly from your Flutter app using Dart.

🛠 Prerequisites

Before generating links, ensure:

  1. Configure ChottuLink Dashboard
    • Set up your project
    • Configure iOS app settings
    • Configure Android app settings
    • Get your API key
  2. Install ChottuLink Flutter SDK
    • Using pub.dev (recommended)
  3. Initialize ChottuLink Flutter SDK
    • Add initialization code to main()
/// ✅ Import ChottuLink SDK packages
import 'package:chottu_link/chottu_link.dart';
import 'package:chottu_link/dynamic_link/cl_dynamic_link_behaviour.dart';
import 'package:chottu_link/dynamic_link/cl_dynamic_link_parameters.dart';

/// Create dynamic link parameters
final parameters = CLDynamicLinkParameters(
link: Uri.parse("https://example.com"), // Target deep link
domain: "yourapp.chottu.link", // Your ChottuLink domain

// Set behavior for Android & iOS
androidBehaviour: CLDynamicLinkBehaviour.app,
iosBehaviour: CLDynamicLinkBehaviour.app,

// UTM Tracking (for analytics)
utmCampaign: "exampleCampaign",
utmMedium: "exampleMedium",
utmSource: "exampleSource",
utmContent: "exampleContent",
utmTerm: "exampleTerm",

// Optional metadata
linkName: "linkname",
selectedPath: "customPath",
socialTitle: "Social Title",
socialDescription: "Description to show when shared",
socialImageUrl: "https://yourdomain.com/image.png", // Must be a valid image URL
);
ChottuLink.createDynamicLink(
parameters: parameters,
onSuccess: (link) {
debugPrint("✅ Shared Link: $link"); // 🔗 Successfully created link
},
onError: (error) {
debugPrint("❌ Error creating link: ${error.description}");
},
);
info
  • Default behavior is set to .app for both platforms
  • selectedPath is optional - if not provided, a random path will be generated
  • SocialParameters is optional - enhances link previews when shared
  • UTMParameters is optional - helps track campaign performance

The CLDynamicLinkBehaviour enum controls how your dynamic link behaves on different platforms.

Available Behaviors

enum CLDynamicLinkBehaviour {
app, // Opens the app if installed, else falls back to Playstore/Appstore
browser // Always opens in browser
}
tip

Each behavior can be set independently for iOS and Android platforms, allowing for platform-specific user experiences.

Open in App

CLDynamicLinkBehaviour.app

How it works

  • Opens your app if installed
  • Falls back to Playstore/Appstore if app is not installed
  • Best for deep linking to specific content

When to Use .app

  • Deep linking to specific app content
  • Providing seamless user experience
  • App functionality is required

Example

androidBehaviour: CLDynamicLinkBehaviour.app,
iosBehaviour: CLDynamicLinkBehaviour.app,

Always Browser

CLDynamicLinkBehaviour.browser

How it works

  • Always opens in browser
  • Useful for marketing campaigns
  • Good for analytics tracking

When to Use .browser

  • Running marketing campaigns
  • Sharing content that works well in browser
  • Need consistent analytics tracking

Example

androidBehaviour: CLDynamicLinkBehaviour.browser,
iosBehaviour: CLDynamicLinkBehaviour.browser,

💡 Best Practices

  • Always provide a valid destination URL
  • Use meaningful link names for better organization
  • Set appropriate platform behaviors
  • Include UTM parameters for tracking
  • Add social parameters for better sharing
  • Test links on both iOS and Android

✅ Next Steps