Skip to content

Guide · Flutter

Add an affiliate or referral program to your Flutter app.

The influto package detects referred installs and takes typed referral codes on iOS and Android. Purchases reach InfluTo through RevenueCat, or straight from the App Store and Google Play with the companion package influto_iap.

Updated November 1, 2026

In short

Run flutter pub add influto, call InfluTo.instance.initialize once at startup, then checkAttribution and identifyUser. On RevenueCat, pass a revenueCatHook that calls Purchases.setAttributes: Flutter has no automatic tagging, so without the hook nothing sets the attribute. Without RevenueCat, add influto_iap and enable an InfluToPurchaseObserver after initialize; it reports new purchases and back-fills earlier ones through the in_app_purchase plugin. Requires Flutter 3.22+ and Dart 3.4+. Plan for an afternoon, most of it on the purchase side.

Which packages you need

There are two packages on pub.dev, both MIT-licensed, with source at github.com/influto/influto-flutter:

  • influto, always. Attribution, referral codes, user identification, free-access codes and manual purchase reporting. Its only dependencies are http and shared_preferences.

  • influto_iap, only for store-direct. Add it if your app doesn't use RevenueCat and sells through the in_app_purchase plugin; it captures purchases automatically. RevenueCat apps on purchases_flutter don't need it.

Everything goes through InfluTo.instance; there are no static calls. The install:

flutter pub add influto
# optional: automatic store-direct purchase capture
flutter pub add influto_iap

Step 1: initialize without holding up the first frame

Call initialize once at startup and wait for it before calling anything else; until it has succeeded, checkAttribution and reportPurchase throw an InfluToException. It throws when it fails (a wrong key, no network), so catch the error, log it and carry on. The next launch tries again.

Don't block your first frame on it: configure RevenueCat, call runApp, then start InfluTo with unawaited, as below. Pass the API key (it_…, on Setup & SDK) at build time with --dart-define=INFLUTO_API_KEY=it_… and read it with String.fromEnvironment.

checkAttribution then tells you whether the install was referred and by which code. The answer is decided once per install and stored on the device, and a network error returns attributed: false without storing anything. A typical main.dart:

import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:influto/influto.dart';
import 'package:purchases_flutter/purchases_flutter.dart'; // only if you use RevenueCat

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Purchases.configure(PurchasesConfiguration('appl_…')); // RevenueCat apps: configure it first
  runApp(const MyApp());
  unawaited(startInfluTo());
}

Future<void> startInfluTo() async {
  try {
    await InfluTo.instance.initialize(InfluToConfig(
      apiKey: const String.fromEnvironment('INFLUTO_API_KEY'),
      appVersion: '1.4.0',
      revenueCatHook: (attrs) => Purchases.setAttributes(attrs),
    ));
  } catch (e) {
    debugPrint('InfluTo initialize failed: $e'); // retried on the next launch
    return;
  }
  final attribution = await InfluTo.instance.checkAttribution();
  await InfluTo.instance.identifyUser(await Purchases.appUserID);
}

Step 2: let users type a code

applyCode(code) validates a code and applies it if it's valid; result.applied tells you whether it was. Codes are trimmed and uppercased, and an invalid one returns valid: false with an errorCode such as CODE_NOT_FOUND or CODE_EXPIRED.

The ready-made option is the ReferralCodeInput widget (Material). It validates as the user types, applies the code on tap, pre-fills it from a link-attributed install and takes your translated texts. It shows a creator's name only if you set showReferrerName.

Step 3: connect purchases

InfluTo only pays commission on purchases verified with the store. Pick exactly one path per platform:

  • RevenueCat (purchases_flutter): pass a revenueCatHook in InfluToConfig that calls Purchases.setAttributes, as in main.dart above. The SDK calls it once, when a referral is found or a code is applied, with influto_code and influto_referral. Then connect the RevenueCat webhook on Setup & SDK.

  • Store-direct (in_app_purchase): add influto_iap, create one InfluToPurchaseObserver and enable it after initialize has finished. It only runs when the app is set to store-direct in Settings → Validation, so the same build is safe on a RevenueCat app.

Without the hook, nothing sets the RevenueCat attribute in Flutter; unlike React Native, there's no automatic tagging. Configure RevenueCat before checkAttribution, and call identifyUser with the RevenueCat app user ID as the fallback InfluTo uses when an event arrives without the attribute.

What the observer does inside your app: it completes pending purchases (completePurchase) so the store doesn't redeliver or refund them; its back-fill calls restorePurchases(), so your own listener also sees restored purchases at startup (enable(backSync: false) skips that); and on iOS it switches in_app_purchase to StoreKit 2, which store-direct needs.

Android one-time products go in the observer's oneTimeProductIds, not in InfluToConfig. To report purchases yourself instead, set autoCapture: false, skip the observer and call reportPurchase with the StoreKit 2 signed transaction or the Play purchaseToken. The observer setup:

import 'package:influto_iap/influto_iap.dart';

final observer = InfluToPurchaseObserver(
  oneTimeProductIds: {'coins_100', 'remove_ads'}, // Android one-time products; omit if you only sell subscriptions
);
final sync = await observer.enable(); // listens for new purchases + back-fills existing ones

Step 4: test it end to end

Sandbox purchases never move money or change your stats:

  1. 1

    Check Setup & SDK. After the first successful initialize it shows “SDK connected” with the platform and SDK version; debug: true prints each step with debugPrint.

  2. 2

    Simulate a purchase. Simulate a purchase on Setup & SDK sends a sandbox test purchase through InfluTo's real pipeline. Enter one of your codes to see it resolve.

  3. 3

    Install through a referral link. Join your campaign with a second creator account, open its link on a test device, install and launch. Typing the code is the most reliable test.

  4. 4

    Buy in the sandbox. Use a TestFlight or sandbox tester (on store-direct iOS, set the Apple environment to Sandbox first) or a Google Play license tester. The Integration log, switched to Sandbox, shows the purchase attributed. enable() returns fetched, sent and failed counts for debugging.

clearAttribution() resets the device for another run.

Flutter notes

Three things that trip people up in Flutter integrations:

  • Order matters. Configure RevenueCat, then initialize, then checkAttribution. Enable the influto_iap observer only after initialize has finished, or it stays off.

  • const configs. InfluToConfig has a const constructor, but a closure isn't a constant, so drop const when you pass a revenueCatHook.

  • Identify once. Call identifyUser once per sign-in, ideally in the user's first session, not from build.

Or let your coding agent do it

Connect InfluTo's MCP server to Claude Code, Codex or Cursor and ask for the integration: the agent maps a Dart project to this SDK, writes the code for the validation path you pick and checks influto_integration_status until a sandbox purchase arrives attributed.

Flutter affiliate SDK, answered.

Is there an affiliate SDK for Flutter?

Yes. influto on pub.dev (MIT, source at github.com/influto/influto-flutter) adds referred-install detection, referral codes and purchase attribution to Flutter apps on iOS and Android. It needs Flutter 3.22+ and Dart 3.4+.

Which referral tools support Flutter?

Several affiliate platforms publish Flutter packages. InfluTo's covers attribution, typed codes with a ready-made ReferralCodeInput widget, RevenueCat tagging through a hook, and automatic store-direct capture through influto_iap. It shares one wire contract with InfluTo's iOS, Android, React Native and web SDKs.

Does it work with purchases_flutter (RevenueCat)?

Yes. Pass a revenueCatHook that calls Purchases.setAttributes, configure RevenueCat first, and connect the RevenueCat webhook. A RevenueCat app doesn't need influto_iap.

Will influto_iap interfere with my own purchase listener?

It completes pending purchases and runs a restore at startup for the back-fill, so your listener also sees restored purchases; call enable(backSync: false) if you don't want that. You still deliver content from your own purchaseStream listener.

What does it cost?

$0 a month. Per verified purchase you pay the commission you set plus 10% of the same revenue (7%, 5% or 3% at volume). The prepaid wallet starts at $50 and is refundable; InfluTo pays creators monthly through Stripe Connect in 33 countries once they've earned $20.

Ship referral codes in your next Flutter build.

One package, one validation path, a refundable deposit. $0 a month; 10% only on revenue creators bring in.

Start free