Flutter

Overview

The following documentation outlines the APIs available for use in the TrustArc Mobile Consent SDK for Flutter.

FlutterTrustarcMobileConsentSdk Class

The FlutterTrustarcMobileConsentSdk class is the main entry point for interacting with the TrustArc SDK in Flutter. All methods are async and return Futures.

Initialization Methods
Method Parameters Return Description
initialize SdkMode sdkMode Future<void> Initializes the SDK with the specified mode. Must be called before start().
start String domainName
String country
String language
Future<void> Starts the SDK with domain, country, and language. Triggers initialization and consent event flows via the subscribe() callbacks.
Consent Event Subscription
Method Parameters Return Description
subscribe onSdkInitFinish: Function(bool, String?)
onConsentChanges: Function()
onGoogleConsentChanges: Function()
void Registers event callbacks. onSdkInitFinish receives (bool isInitialized, String? message). All callbacks are optional.
Consent UI Methods
Method Parameters Return Description
openCM None Future<void> Opens the consent manager window.
Consent Data Methods
Method Parameters Return Description
isConsentPresent None Future<bool> Returns whether consent data is present on the device.
isCategoryConsented int categoryIndex Future<bool> Returns whether the specified consent category is consented.
getStoredConsentData None Future<String> Returns a JSON-encoded string of flat domain consent values.
getConsentDataByCategory None Future<String> Returns a JSON-encoded string of consent data grouped by category.
getGoogleConsents None Future<String> Returns a JSON-encoded string of Google Consent Mode values.
getIABTCFPreferences None Future<IABTCFPreferences> Returns the stored IAB TCF consent preferences. Only meaningful in IAB TCF v2.2 mode.
getWebScript None Future<String> Returns a JavaScript string for injection into a WebView for web consent integration.
setKnownUser String userId Future<void> Sets a known user identifier for cross-device consent sync. Must be called before start().
SdkMode

Enum passed to initialize() to select the SDK operating mode.

Value Description
SdkMode.standard Default SDK mode for standard consent management.
SdkMode.iabTCFv_2_2 IAB Transparency and Consent Framework v2.2 mode. Use when the client is a publisher serving ads to EU/EEA users and requires IAB TCF vendor consent signaling.
IABTCFPreferences

Type definition for IAB TCF (Transparency & Consent Framework) preferences. Returned by getIABTCFPreferences() when operating in IAB TCF v2.2 mode.

Field Description
IABTCF_PurposeOneTreatment Indicates if Purpose One has special treatment (0 = no, 1 = yes).
IABTCF_VendorConsents Encoded string representing vendor consents.
IABTCF_enableAdvertiserConsentMode Whether advertiser consent mode is enabled. Google's latest Firebase SDK for iOS and Android now supports TCF. To ensure proper consent handling, set IABTCF_enableAdvertiserConsentMode to 1 when using TCF so Google can infer consent from the TC string.
IABTCF_PublisherCC Publisher's country code (e.g., "DE", "FR").
IABTCF_PublisherConsent Encoded string representing publisher-specific consent.
IABTCF_gdprApplies Indicates if GDPR applies (0 = no, 1 = yes).
IABTCF_SpecialFeaturesOptIns Encoded string representing special feature opt-ins.
IABTCF_VendorLegitimateInterests Encoded string representing vendor legitimate interests.
IABTCF_PublisherLegitimateInterests Encoded string representing publisher legitimate interests.
IABTCF_PublisherCustomPurposesConsents Encoded string representing publisher custom purposes consents.
IABTCF_TCString TC string containing the encoded user consent data.
IABTCF_UseNonStandardTexts Indicates if non-standard text versions are used (0 = no, 1 = yes).
IABTCF_PolicyVersion IAB TCF policy version number.
IABTCF_PurposeConsents Encoded string representing purpose consents.
IABTCF_PurposeLegitimateInterests Encoded string representing purpose legitimate interests.
IABTCF_CmpSdkID CMP SDK ID.
IABTCF_CmpSdkVersion CMP SDK version.
IABTCF_PublisherCustomPurposesLegitimateInterests Encoded string representing publisher custom purposes legitimate interests.
TrustArc  ·  Mobile App Consent — API Reference: Flutter  ·  www.trustarc.com