Skip to main content

Flutter Integration

This guide will help you configure your Flutter app for ChottuLink Dynamic Links. You can complete this setup either during the initial onboarding or later from your project settings.

Prerequisites​

Before integrating ChottuLink into your Flutter app, ensure you have the following:

Development Environment​

  • Flutter SDK installed (Flutter v3.3.0 or later recommended)
  • Dart SDK installed (Dart v3.1.0 or later recommended)
  • A working Flutter project targeting iOS 15.0+ and Android 5.0+ (API 21+)
  • Xcode 16.2 or later installed (for iOS)
  • Android Studio or other IDE with Android SDK installed
  • Physical devices or simulators/emulators to run your app
  • Git for version control
Dart Support — v3.5.0

Dart v3.5.0 is supported starting from ChottuLink v1.0.11 and above.

1. For iOS - Click here​

2. For Android - Click here​

Installation​

dependencies:
flutter:
sdk: flutter
chottu_link: ^1.1.4

Click here to get the latest version.​

2. Then run:​

flutter pub get

Platform Specific Configurations​

1. For iOS​

Configure Associated Domains​

Associated Domains are configured to securely link your app with your website. Without this setup, features like Universal Links won't function properly, resulting in a less seamless user experience.

  1. Open your project in Xcode
  2. Select your project in the navigator
  3. Select your target under TARGETS
  4. Click on the "Signing & Capabilities" tab
  5. Click the "+" button in the top-left corner of the capabilities section
  6. Search for and select "Associated Domains"

add-capability.png

  1. Add Your Domain
    1. In the Associated Domains section that appears, click the "+" button under "Domains"

    2. Add your domain using the following format:

      applinks:your_dynamic_links_domain

      For example, if your domain is yourapp.chottu.link, you would add:

      applinks:yourapp.chottu.link

      associated-added.png

2. For Android​

Update Your App's Manifest File​

Your app's AndroidManifest.xml file needs a couple of things:

  1. The internet permission (if you haven't added it already).
  2. To know which part of your app should open when a ChottuLink URL is clicked.

Here's how it might look. Make sure to change the highlighted parts!


<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:taskAffinity=""
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">

<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"/>

<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>

<!-- Add the highlighted lines in your manifest -->
<meta-data android:name="flutter_deeplinking_enabled" android:value="false"/>

<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>

<!-- Change "yourapp.chottu.link" to the special domain you set up for your ChottuLink URLs -->
<data
android:scheme="https"
android:host="yourapp.chottu.link"/>
</intent-filter>
</activity>
tip

Remember to change:

  • yourapp.chottu.link to the domain you've set up on ChottuLink Dashboard for your app's links.

Note: You can get the mobile SDK API KEY from ChottuLink Dashboard API Keys section

1. Basic Initialization​

Initialize the SDK in main.dart:

import 'package:chottu_link/chottu_link.dart';

void main() async {
/// ⚠️ Make sure to call this before call ChottuLink.init(apiKey: "your_api_key_here").
WidgetsFlutterBinding.ensureInitialized();

/// ✅ Initialize the ChottuLink SDK
/// Make sure to call this before using any ChottuLink features
/// and before subscribing to ChottuLink.onLinkReceived.
await ChottuLink.init(apiKey: "your_api_key_here");

runApp(MyApp());
}

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter ChottuLink Demo',
home: HomeScreen(),
);
}
}

2. Initialization with Options​

allowedDomains — v1.1.4

The allowedDomains option of ChottuLink.init() is available starting from ChottuLink v1.1.4. See Restricting which links ChottuLink handles.

ChottuLink.init() accepts an optional allowedDomains parameter (available from chottu_link v1.1.4) to control which links ChottuLink handles.

static Future<void> init({
required String apiKey,
List<String>? allowedDomains,
})
ParameterTypeRequiredDescription
apiKeyStringYesYour mobile SDK API key from the ChottuLink Dashboard.
allowedDomainsList<String>?NoDecides which incoming links ChottuLink handles. If null or empty, all links are handled. Available from chottu_link v1.1.4.
await ChottuLink.init(
apiKey: 'YOUR_API_KEY',
allowedDomains: ['shop.myapp.com'],
);

For examples and matching rules, see Restricting which links ChottuLink handles.

By default, ChottuLink handles every link your app receives. Use allowedDomains when:

  • your app uses ChottuLink alongside other deep link providers, or
  • you want ChottuLink to handle only specific domains.

Links that ChottuLink does not handle are left to your app's own deep link handling (go_router, Navigator, etc.).

Examples​

a) No list (default): all links are handled (ChottuLink & all others)

await ChottuLink.init(apiKey: 'YOUR_API_KEY');

b) One domain

await ChottuLink.init(
apiKey: 'YOUR_API_KEY',
allowedDomains: ['links.myapp.com'], // your branded custom domain
);
Custom domains are not added automatically

chottu.link is added automatically, so <tenant>.chottu.link links work without being listed. A branded custom domain is not. If your app uses one, you must add it to allowedDomains yourself, otherwise those links will not be handled by ChottuLink.

Matching rules​

RuleBehavior
null or empty listAll links are handled (previous behavior).
Non-empty listOnly links whose host matches an entry in the list are handled by ChottuLink.
chottu.linkAdded automatically.
Custom domainNot added automatically. Add it yourself.
What is comparedOnly the host. Path, scheme and query are ignored.
SubdomainsMatch. myapp.com also matches shop.myapp.com, but not evil-myapp.com.
NormalizationEntries are lowercased, surrounding spaces are trimmed and a www. prefix is ignored. A full URL such as https://shop.myapp.com is accepted and its host is used.
Host-less linksLinks without a host (for example mailto:) are always skipped once a list is set. They cannot be added to the list.
No usable entriesIf none of the entries are usable (for example all empty strings), filtering stays off and all links are handled.

Call order​

Call ChottuLink.init() before you subscribe to ChottuLink.onLinkReceived, so the list is set before the first link arrives.

Cold start

If your app is opened from a link that arrives before init() completes, the SDK holds it and checks it against your domain list after init(). You don't need to do anything extra on Android or iOS.

Migration​

Existing apps need no changes. If you don't pass allowedDomains, ChottuLink keeps handling all links as before.

Next Steps​

After completing the Flutter setup:

  1. Create your first Dynamic Link
  2. Receive Dynamic Link