Flutter SDK Basic Integration


SDK Stats

GitHub tag (latest by date)GitHub tag (latest by date)


In order to implement the Branch SDK into your Flutter app, you need to have/complete the following:

  1. Created a Branch Dashboard.
  2. Flutter installed.

1. Configure Your Branch Dashboard

Universal for all platforms, you first need to configure your app in the Branch Dashboard. Once logged in, navigate to the Configuration screen to configure your links and redirects.

Default URL

Set a URL here to designate where the user will be redirected to when opening a Branch Link on web.


Input your Android URI scheme to direct the app to open for users clicking on links with the app installed. If you have Android App Links enabled, input your SHA256 Cert Fingerprint as well.

Be sure to set your Google Play store listing as the fallback redirect for users clicking on links without the app installed.

Additional details on setting Android Redirects can be found here.


Input your iOS URI Schemes to direct the app to open for users clicking on links with the app installed. Add your app's bundle identifiers and Apple App Prefix for Universal Links.

Be sure to set your App Store listing as the fallback redirect for users clicking on links without the app installed.

Additional details on setting iOS Redirects can be found here.

2. Configure Native Platforms

In order to set up Branch, you will need to configure each platform to prepare for session initialization.


For Android, you need to configure your AndroidManifest.xml file,


For iOS, you need to configure the following:


For Web, you need to add the Branch Javascript in your web\index.html at the top of your <body> tag

  (function(b,r,a,n,c,h,_,s,d,k){if(!b[n]||!b[n]._q){for(;s<_.length;)c(h,_[s++]);d=r.createElement(a);d.async=1;d.src="https://cdn.branch.io/branch-latest.min.js";k=r.getElementsByTagName(a)[0];k.parentNode.insertBefore(d,k);b[n]=h}})(window,document,"script","branch",function(b,r){b[r]=function(){b._q.push([r,arguments])}},{_q:[],_v:1},"addListener applyCode autoAppIndex banner closeBanner closeJourney creditHistory credits data deepview deepviewCta first getCode init link logout redeem referrals removeListener sendSMS setBranchViewData setIdentity track validateCode trackCommerceEvent logEvent disableTracking".split(" "), 0);

3. Install Branch

Add the Dependency

Run the following command in terminal flutter pub get to add the Flutter Branch SDK package.

flutter pub add flutter_branch_sdk

This will add the Flutter Branch SDK to your project's pubspec file.

  flutter_branch_sdk: ^5.0.0

Import Branch Package

In your Dart code, import Branch:

import 'package:flutter_branch_sdk/flutter_branch_sdk.dart';

4. Initialize Branch

In your main Dart file, you need to initialize the Branch Session listener before being able to use any of the SDK methods. A listener should be called early on in your initState() method:

FlutterBranchSdk.initSession().listen((data) {

Validate Integration

After initializing Branch, you can validate your integration verify your keys, schemes, etc. using the validateSDKIntegration() method. Do not forget to remove this line after validation.


5. Configure Deep Linking

Firstly, when your Branch Session is initialized, the you'll want to configure your deep linking routing logic.

StreamSubscription<Map> streamSubscription = FlutterBranchSdk.initSession().listen((data) {
  if (data.containsKey("+clicked_branch_link") &&
      data["+clicked_branch_link"] == true) {
    //Link clicked. Add logic to get link data and route user to correct screen
    print('Custom string: ${data["custom_string"]}');
}, onError: (error) {
  PlatformException platformException = error as PlatformException;
    'InitSession error: ${platformException.code} - ${platformException.message}');

6. Track Events

Track relevant events using BranchEvent in order to properly attribute your campaign performance outside of app installs and opens. BranchEvent provides an interface to add contents represented by a BranchUniversalObject in order to associate app contents with events.

Additional details on event tracking can be found here.

Set ContentMetaData

BranchContentMetaData metadata = BranchContentMetaData()
  ..addCustomMetadata('custom_string', 'abc')
  ..addCustomMetadata('custom_number', 12345)
  ..addCustomMetadata('custom_bool', true)
  ..addCustomMetadata('custom_list_number', [1, 2, 3, 4, 5])
  ..addCustomMetadata('custom_list_string', ['a', 'b', 'c'])
  //--optional Custom Metadata
  ..contentSchema = BranchContentSchema.COMMERCE_PRODUCT
  ..price = 50.99
  ..currencyType = BranchCurrencyType.BRL
  ..quantity = 50
  ..sku = 'sku'
  ..productName = 'productName'
  ..productBrand = 'productBrand'
  ..productCategory = BranchProductCategory.ELECTRONICS
  ..productVariant = 'productVariant'
  ..condition = BranchCondition.NEW
  ..rating = 100
  ..ratingAverage = 50
  ..ratingMax = 100
  ..ratingCount = 2
    street: 'street',
    city: 'city',
    region: 'ES',
    country: 'Brazil',
    postalCode: '99999-987')
  ..setLocation(31.4521685, -114.7352207);

Set Content Reference

BranchUniversalObject buo = BranchUniversalObject(
  canonicalIdentifier: 'flutter/branch',
  //parameter canonicalUrl
  //If your content lives both on the web and in the app, make sure you set its canonical URL
  // (i.e. the URL of this piece of content on the web) when building any BUO.
  // By doing so, we’ll attribute clicks on the links that you generate back to their original web page,
  // even if the user goes to the app instead of your website! This will help your SEO efforts.
  canonicalUrl: 'https://flutter.dev',
  title: 'Flutter Branch Plugin',
  contentDescription: 'Flutter Branch Description',
  contentMetadata: metadata,
  keywords: ['Plugin', 'Branch', 'Flutter'],
  publiclyIndex: true,
  locallyIndex: true,
  DateTime.now().add(Duration(days: 365)).millisecondsSinceEpoch);

Track Event

//Track Standard Event
BranchEvent eventStandart = BranchEvent.standardEvent(BranchStandardEvent.ADD_TO_CART)
  //--optional Event data
  ..transactionID = '12344555'
  ..currency = BranchCurrencyType.BRL
  ..revenue = 1.5
  ..shipping = 10.2
  ..tax = 12.3
  ..coupon = 'test_coupon'
  ..affiliation = 'test_affiliation'
  ..eventDescription = 'Event_description'
  ..searchQuery = 'item 123'
  ..adType = BranchEventAdType.BANNER
  'Custom_Event_Property_Key1', 'Custom_Event_Property_val1')
  'Custom_Event_Property_Key2', 'Custom_Event_Property_val2');
FlutterBranchSdk.trackContent(buo: [buo], branchEvent: eventStandart);

//Track Custom Event
BranchEvent eventCustom = BranchEvent.customEvent('Custom_event')
  'Custom_Event_Property_Key1', 'Custom_Event_Property_val1')
  'Custom_Event_Property_Key2', 'Custom_Event_Property_val2');
FlutterBranchSdk.trackContent(buo: [buo], branchEvent: eventCustom);

Recommended Next Steps
Did this page help you?