ReflectDocs
Browse docsOverview
Flutter SDK

Flutter SDK

Reflect SDK for Flutter — mobile attribution, event tracking, deep linking, and SKAN. Zero third-party dependencies.

Installation

Add the dependency to your pubspec.yaml:

dependencies:
  reflect_sdk:
    git:
      url: https://github.com/bablu147/reflect-sdk-flutter.git
      ref: v1.1.0

Then run flutter pub get.

Requirements

  • Dart >=3.0.0, Flutter >=3.10.0
  • Android: minSdkVersion 21
  • iOS: 12+
  • No third-party dependencies — only the Flutter SDK itself

Quick start

import 'package:reflect_sdk/reflect_sdk.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await Reflect.initialize(ReflectConfig(
    appKey:     "app_live_...",
    companyKey: "co_live_...",
    baseUrl:    "https://api.reflect.cloud",
  ));

  runApp(MyApp());
}

API reference

MethodDescription
Reflect.initialize(config)Initialize the SDK (call once at app start)
Reflect.trackEvent(name, properties?)Track a named event with optional properties
Reflect.trackRevenue(params)Track a revenue/purchase event
Reflect.setUserId(userId)Set user ID for cross-device attribution
Reflect.clearUserId()Clear user ID (e.g. on logout)
Reflect.setUserProperties(props)Set properties attached to all future events
Reflect.setAdvertisingConsent(granted)Grant/revoke IDFA/GAID consent
Reflect.getInstallUuid()Get the persistent install UUID
Reflect.getAttribution()Get current attribution data
Reflect.updateConversionValue(...)Update SKAN conversion value (iOS only)
Reflect.getInitialDeepLink()Get the deep link that opened the app
Reflect.onDeepLinkStream of deep link events while running
Reflect.setGlobalProperty(key, val)Set a property merged into every event
Reflect.unsetGlobalProperty(key)Remove a global property
Reflect.clearGlobalProperties()Remove all global properties
Reflect.setAudience(tags)Tag the install for audience segmentation
Reflect.trackPurchase(params)Track a purchase event with optional receipt
Reflect.trackSubscription(params)Track a subscription event
Reflect.deleteUserData()GDPR — delete all user data
Reflect.requestIosTracking()Request iOS ATT permission (returns status)
Reflect.setEnabled(enabled)Enable/disable the SDK at runtime
Reflect.flush()Force-flush buffered events

Event tracking

// Simple event
await Reflect.trackEvent("level_complete", properties: {
  "level": 5,
  "score": 12340,
});

// Revenue event
await Reflect.trackRevenue(RevenueParams(
  amount: 4.99,
  currency: "USD",
  productId: "gems_500",
  transactionId: "txn_abc123",
));

Deep linking

// Get the link that launched the app
final initial = await Reflect.getInitialDeepLink();
if (initial != null) {
  navigateTo(initial.path);
}

// Listen for links while running
Reflect.onDeepLink.listen((data) {
  navigateTo(data.path);
});

SKAN (iOS)

final result = await Reflect.updateConversionValue(
  42,
  coarseValue: "high",
  lockWindow: false,
);
if (!result.success) print("SKAN error: ${result.error}");

Standard events

Pre-built helpers with typed parameters (v1.1.0+):

import 'package:reflect_sdk/reflect_sdk.dart';

ReflectStandardEvents.signUpWith("google");
ReflectStandardEvents.levelCompleted(5, score: 12340);
ReflectStandardEvents.addedToCart("gems_500", 4.99, "USD");
ReflectStandardEvents.adShown("interstitial", network: "admob");

Global properties

await Reflect.setGlobalProperty("ab_group", "variant_b");
await Reflect.unsetGlobalProperty("ab_group");
await Reflect.clearGlobalProperties();

Purchase & subscription

await Reflect.trackPurchase(PurchaseParams(
  productId: "gems_500",
  price: 4.99,
  currency: "USD",
  receiptData: "<base64-receipt>",
));

await Reflect.trackSubscription(SubscriptionParams(
  productId: "pro_monthly",
  price: 9.99,
  currency: "USD",
  isTrial: true,
));

Privacy (GDPR)

final deleted = await Reflect.deleteUserData();
// Clears local state + sends deletion request to server
v1.1.0 — Feature parity with Unity
Standard event helpers, global properties, audience tagging, purchase/subscription tracking with receipt data, event validation, crash capture, GDPR deletion, and iOS ATT request. All APIs are async (Future<T>), deep links use Stream<DeepLinkData>.