Reference
This section is a comprehensive reference of the methods and events exposed by the Flutter SDK that you can leverage in your application.
These methods are accessible in the DidomiSdk class. Also make sure to always call the SDK after it is fully initialized (see onReady).

addEventListener

Add an event listener to catch events triggered by the SDK. Events listeners allow you to react to different events of interest. This function is safe to call before the ready event has been triggered.
Requires SDK to be initialized
No.
Parameters
Name
Type
Description
eventListener
EventListener
The event listener. An instance ofEventListener
Returns
Nothing
Example
Dart
1
EventListener didomiListener = EventListener();
2
3
didomiListener.onReady = () {
4
// The SDK is ready
5
};
6
7
didomiListener.onError = (message) {
8
// An error occurred
9
};
10
11
didomiListener.onShowNotice = () {
12
// Notice was displayed
13
};
14
15
didomiListener.onHideNotice = () {
16
// Notice was hidden
17
};
18
19
didomiListener.onNoticeClickAgree = () {
20
// Click Agree on Notice
21
};
22
23
didomiListener.onNoticeClickDisagree = () {
24
// Click Disagree on Notice
25
};
26
27
didomiListener.onNoticeClickViewVendors = () {
28
// Click View vendors on Notice
29
};
30
31
didomiListener.onNoticeClickMoreInfo = () {
32
// Click More info on Notice
33
};
34
35
didomiListener.onNoticeClickPrivacyPolicy = () {
36
// Click Privacy policy on Notice
37
};
38
39
didomiListener.onPreferencesClickAgreeToAll = () {
40
// Click Agree to all on Preferences screen
41
};
42
43
didomiListener.onPreferencesClickDisagreeToAll = () {
44
// Click Disagree to all on Preferences screen
45
};
46
47
didomiListener.onPreferencesClickPurposeAgree = (purposeId) {
48
// Click Agree to purpose on Preferences screen
49
};
50
51
didomiListener.onPreferencesClickPurposeDisagree = (purposeId) {
52
// Click Disagree to purpose on Preferences screen
53
};
54
55
didomiListener.onPreferencesClickCategoryAgree = (categoryId) {
56
// Click Agree to category on Preferences screen
57
};
58
59
didomiListener.onPreferencesClickCategoryDisagree = (categoryId) {
60
// Click Disagree to category on Preferences screen
61
};
62
63
didomiListener.onPreferencesClickViewVendors = () {
64
// Click View vendors from Preferences screen
65
};
66
67
didomiListener.onPreferencesClickSaveChoices = () {
68
// Click Save choices from Preferences screen
69
};
70
71
didomiListener.onPreferencesClickVendorAgree = (vendorId) {
72
// Click Agree to vendor on Preferences screen
73
};
74
75
didomiListener.onPreferencesClickVendorDisagree = (vendorId) {
76
// Click Disagree to vendor on Preferences screen
77
};
78
79
didomiListener.onPreferencesClickVendorSaveChoices = () {
80
// Click Save vendor choices from Preferences screen
81
};
82
83
didomiListener.onPreferencesClickViewPurposes = () {
84
// Click View purposes from Preferences screen
85
};
86
87
didomiListener.onConsentChanged = () {
88
// Consent has changed
89
};
90
91
didomiListener.onPreferencesClickAgreeToAllPurposes = () {
92
// Click Agree to all purposes from Preferences screen
93
};
94
95
didomiListener.onPreferencesClickDisagreeToAllPurposes = () {
96
// Click Disagree to all purposes from Preferences screen
97
};
98
99
didomiListener.onPreferencesClickResetAllPurposes = () {
100
// Click Reset all purposes from Preferences screen
101
};
102
103
didomiListener.onPreferencesClickAgreeToAllVendors = () {
104
// Click Agree to all vendors from Preferences screen
105
};
106
107
didomiListener.onPreferencesClickDisagreeToAllVendors = () {
108
// Click Disagree to all vendors from Preferences screen
109
};
110
111
DidomiSdk.addEventListener(didomiListener);
Copied!
Event types
The following events are supported by the Didomi SDK:
Method
Description
onConsentChanged
When a consent is given or withdrawn by the user. Only triggered when the consent status actually changes (ie if the user saves consents without adding/removing any consent then this does not get called).
onHideNotice
When the consent notice is hidden. If you have disabled our default consent notice to replace it with your own, you need to hide your custom notice when this event gets triggered.
onShowNotice
When the consent notice gets displayed. If you have disabled our default consent notices to replace them with your own, you need to show your custom notice when this event gets triggered.
onNoticeClickAgree
When user clicks on agree on the notice
onNoticeClickMoreInfo
When user clicks on learn more on the notice
onPreferencesClickAgreeToAll
When user clicks on agree to all on the preferences popup
onPreferencesClickDisagreeToAll
When user clicks on disagree to all on the preferences popup
onPreferencesClickPurposeAgree
When user agree to a purpose on the preferences popup. (purposeId provided as a parameter)
onPreferencesClickPurposeDisagree
When user disagree to a purpose on the preferences popup. (purposeId provided as a parameter)
onPreferencesClickViewVendors
When user clicks on view vendors on the preferences popup
onPreferencesClickSaveChoices
When user saves his choice on the preferences popup
onPreferencesClickVendorAgree
When user agree to a vendor on the preferences popup. (vendorId provided as a parameter)
onPreferencesClickVendorDisagree
When user disagree to a vendor on the preferences popup. (vendorId provided as a parameter)
onPreferencesClickVendorSaveChoices
When user saves his choice on the vendors view on the preferences popup
onNoticeClickDisagree
When user clicks on disagree on the notice
onNoticeClickViewVendors
When user clicks on partners on the notice
onNoticeClickPrivacyPolicy
When user clicks on privacy policy on the notice
onPreferencesClickAgreeToAllPurposes
When user flips ON all purposes switch on the preferences popup
onPreferencesClickDisagreeToAllPurposes
When user flips OFF all purposes switch on the preferences popup
onPreferencesClickAgreeToAllVendors
When user flips ON all vendors switch on the preferences popup
onPreferencesClickDisagreeToAllVendors
When user flips OFF all vendors switch on the preferences popup
onPreferencesClickViewPurposes
When user clicks on view purposes on the preferences popup

getDisabledPurposes

Get the list of purposes that have been disabled by the user.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
Type
Description
Future<List<Purpose>>
A list of type Purpose containing the purposes disabled by the user.
Example
Dart
1
await DidomiSdk.getDisabledPurposes();
Copied!

getDisabledPurposeIds

Get the list of purpose IDs that have been disabled by the user.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
Type
Description
Future<List<String>>
A list of type String containing the IDs of purposes disabled by the user.
Example
Dart
1
await DidomiSdk.getDisabledPurposeIds()
Copied!

getDisabledVendors

Get the list of vendors that have been disabled by the user.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
Type
Description
Future<List<Vendor>>
A list of type Vendor containing the vendors disabled by the user.
Example
Dart
1
await DidomiSdk.getDisabledVendors();
Copied!

getDisabledVendorIds

Get the list of vendor IDs that have been disabled by the user.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
Type
Description
Future<List<String>>
A list of type String containing the IDs of vendors disabled by the user.
Example
Dart
1
await DidomiSdk.getDisabledVendorIds();
Copied!

getEnabledPurposes

Get the list of purposes that have been enabled by the user.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
Type
Description
Future<List<Purpose>>
A list of type Purpose containing the purposes enabled by the user.
Example
Dart
1
await DidomiSdk.getEnabledPurposes();
Copied!

getEnabledPurposeIds

Get the list of purpose IDs that have been enabled by the user.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
Type
Description
Future<List<String>>
A list of type String containing the IDs of purposes enabled by the user.
Example
Dart
1
await DidomiSdk.getEnabledPurposeIds();
Copied!

getEnabledVendors

Get the list of vendors that have been enabled by the user.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
Type
Description
Future<List<Vendor>>
A list of type Vendor containing the vendors enabled by the user.
Example
Dart
1
await DidomiSdk.getEnabledVendors();
Copied!

getEnabledVendorIds

Get the list of vendor IDs that have been enabled by the user.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
Type
Description
Future<List<String>>
A list of type String containing the IDs of vendors enabled by the user.
Example
Dart
1
await DidomiSdk.getEnabledVendorIds();
Copied!

getJavaScriptForWebView

Get JavaScript to embed into a WebView to pass the consent status from the app to the Didomi Web SDK embedded into the WebView.
Inject the returned tag into a WebView with evaluateJavaScript.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
Type
Description
Future<String>
JavaScript code to embed in a WebView
Example
Dart
1
await DidomiSdk.javaScriptForWebView;
Copied!

getQueryStringForWebView

Get a query string parameter to append to the URL of a WebView to pass the consent status from the app to the Didomi Web SDK embedded into the WebView.
Read our article on sharing consent with WebViews for more information.
This method is currently available on Android platform only. Calling getQueryStringForWebView on iOS platform will return an empty String.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
Type
Description
Future<String>
Query string parameter with the format didomiConfig.user.externalConsent.value=.... It can be appended to your URL after a ? or a & if your URL already contains a query string.
Example
Dart
1
await DidomiSdk.queryStringForWebView;
Copied!

getPurpose

Get a purpose based on its ID.
Requires SDK to be initialized
Yes.
Parameters
Name
Type
Description
purposeId
String
ID of the purpose we want to get.
Returns
Type
Description
Future<Purpose?>
A Purpose with ID purposeId found in the array of required purposes, or null.
Example
Dart
1
await DidomiSdk.getPurpose("purpose-id");
Copied!

getRequiredPurposes

Get the list of purpose that are required (automatically determined from the list of required vendors).
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
Type
Description
Future<List<Purpose>>
A list of type Purpose containing the required purposes.
Example
Dart
1
await DidomiSdk.requiredPurposes;
Copied!

getRequiredPurposeIds

Get the list of purpose IDs that are required (automatically determined from the list of required vendors).
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
Type
Description
Future<List<String>>
A list of type String containing the IDs of required purposes.
Example
Dart
1
await DidomiSdk.requiredPurposeIds;
Copied!

getRequiredVendors

Get the list of vendors that are required (determined from the configuration).
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
Type
Description
Future<List<Vendor>>
A list of type Vendor containing the required vendors.
Example
Dart
1
await DidomiSdk.requiredVendors;
Copied!

getRequiredVendorIds

Get the list of vendor IDs that are required (determined from the configuration).
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
Type
Description
Future<List<String>>
A list of type String containing the IDs of required vendors.
Example
Dart
1
await DidomiSdk.requiredVendorIds;
Copied!

getText

Method used to get a dictionary/map based on the key being passed. These keys and texts are extracted from the notice content, preferences content and the texts property specified in the didomi_config.json file as described here https://developers.didomi.io/cmp/mobile-sdk/consent-notice/customize-the-theme#translatable-texts-for-custom-notices.
Requires SDK to be initialized
Yes.
Parameters
Name
Type
Description
key
String
key associated to the dictionary that we want to get.
Returns
Type
Description
Dictionary/map: Future<Map<String, String>>
Dictionary/map containing the translations for an specific key in different languages, with the form { "en:" "text in English", "fr": "texte en Français" }
Example
Dart
1
await DidomiSdk.getText("key");
Copied!

getTranslatedText

Method used to get a translated text based on the key being passed.
The language and the source of this translated text will depend on the availability of the translation for the specific key.
The language being used will be either the selected language of the SDK (based on device Locale and other parameters) or the language specified by app developers as the default language being used by the SDK. The source can be either the didomi_config.json file, which can be either local or remote, or a file that is bundled within the SDK.
These are the attempts performed by the SDK to try to find a translation for the specific key:
  • Get translated value in user locale (selected language) from didomi_config.json (either local or remote).
  • Get translated value in default locale (from the config) from didomi_config.json (either local or remote).
  • Get translated value in user locale (selected language) from the Didomi-provided translations (bundled within the Didomi SDK).
  • Get translated value in default locale (from the config) from the Didomi-provided translations (bundled within the Didomi SDK).
If no translation can be found after these 4 attempts, the key will be returned.
App developers can provide these translated texts through the didomi_config.json file (locally or remotely) in 3 different ways:
Requires SDK to be initialized
Yes.
Parameters
Name
Type
Description
key
String
key associated to the text that we want to get translated.
Returns
Translated text.
Example
Dart
1
await DidomiSdk.getTranslatedText("key");
Copied!

getUserConsentStatusForPurpose

Get the user consent status for a given purpose. You must also check that the user has given consent to a vendor before being able to load a vendor.
Parameters
Name
Type
Description
purposeId
String
The ID of the purpose to check the user consent for
Returns
A ConsentStatus that indicates if the user has given consent or not to the specific purpose.
1
enum ConsentStatus { disable, enable, unknown }
Copied!
unknown is returned if the consent status is not known yet. From a GDPR perspective, you'll want to treat unknown as disable (ie no consent given) but it is helpful to know that the user has not interacted with the consent UI yet so that you can subscribe to events and wait for consent information to be collected.
If consent is not required because GDPR does not apply to that user, this function will return enable.
Example
Dart
1
await DidomiSdk.getUserConsentStatusForPurpose("analytics");
Copied!

getUserConsentStatusForVendor

Get the user consent status for a given vendor. You must also check that the user has given consent to some or all of the purposes required by a vendor before loading the vendor. The function getUserConsentStatusForVendorAndRequiredPurposes does all the required checks for you so it might be a better choice.
Parameters
Name
Type
Description
vendorId
String
The ID of the vendor to check the user consent for. If you are checking an IAB vendor, pass the number as a String. If you are checking a custom vendor, prefix your vendor ID with c:.
Returns
A ConsentStatus that indicates if the user has given consent or not to the specific vendor.
1
enum ConsentStatus { disable, enable, unknown }
Copied!
unknown is returned if the consent status is not known yet. From a GDPR perspective, you'll want to treat unknown as disable (ie no consent given) but it is helpful to know that the user has not interacted with the consent UI yet so that you can subscribe to events and wait for consent information to be collected.
If consent is not required because GDPR does not apply to that user, this function will return enable.
Example
Dart
1
// IAB vendors
2
await DidomiSdk.getUserConsentStatusForVendor("1");
3
4
// Didomi vendors
5
await DidomiSdk.getUserConsentStatusForVendor("google");
6
7
// Custom vendors (prefix vendor ID with c:)
8
await DidomiSdk.getUserConsentStatusForVendor("c:custom-vendor-id");
Copied!

getUserConsentStatusForVendorAndRequiredPurposes

Get the user consent status for a given vendor. We use the list of purposes declared for the vendor to make sure that it has consent for all of them. The required purposes are automatically setup for IAB or Didomi vendors and you must specify the required purposes for your custom vendors when configuring the tag.
Parameters
Name
Type
Description
vendorId
String
The ID of the vendor to check the user consent for.
If you are checking an IAB vendor, pass the number as a String.
If you are checking a custom vendor, prefix your vendor ID with c:.
Returns
A ConsentStatus that indicates if the user has given consent or not to the specific vendor and all the purposes that require consent for that vendor.
1
enum ConsentStatus { disable, enable, unknown }
Copied!
unknown is returned if the consent status is not known yet. From a GDPR perspective, you'll want to treat unknown as disable (ie no consent given) but it is helpful to know that the user has not interacted with the consent UI yet so that you can subscribe to events and wait for consent information to be collected.
If consent is not required because GDPR does not apply to that user, this function will return enable.
Example
Dart
1
// IAB vendors
2
await DidomiSdk.getUserConsentStatusForVendorAndRequiredPurposes("1");
3
4
// Didomi vendors
5
await DidomiSdk.getUserConsentStatusForVendorAndRequiredPurposes("google");
6
7
// Custom vendors (prefix vendor ID with c:)
8
await DidomiSdk.getUserConsentStatusForVendorAndRequiredPurposes("c:custom-vendor-id");
Copied!

getUserLegitimateInterestStatusForPurpose

Get the user legitimate interest status for a given purpose.
Parameters
Name
Type
Description
purposeId
String
The ID of the purpose to check the user legitimate interest for.
Returns
A ConsentStatus that indicates if the user has allowed legitimate interest data processing to the specific purpose.
1
enum ConsentStatus { disable, enable, unknown }
Copied!
unknown is returned if the legitimate interest status is not known yet. From a GDPR perspective, you'll want to treat unknown as disable (ie no legitimate interest status given) but it is helpful to know that the user has not interacted with the legitimate interest UI yet so that you can subscribe to events and wait for legitimate interest information to be collected.
Example
Dart
1
await DidomiSdk.getUserLegitimateInterestStatusForPurpose("measure_ad_performance);
Copied!

getUserLegitimateInterestForVendor

Get the user legitimate interest status for a given vendor. You must also check that the user has allowed legitimate interest data processing for some or all of the purposes required by a vendor before loading the vendor. The function getUserLegitimateInterestStatusForVendorAndRequiredPurposes does all the required checks for you so it might be a better choice.
Parameters
Name
Type
Description
vendorId
String
The ID of the vendor to check the user legitimate interest status for. If you are checking an IAB vendor, pass the number as a String. If you are checking a custom vendor, prefix your vendor ID with c:.
Returns
A ConsentStatus that indicates if the user has allowed legitimate interest data processing for the specific vendor.
1
enum ConsentStatus { disable, enable, unknown }
Copied!
unknown is returned if the legitimate interest status is not known yet. From a GDPR perspective, you'll want to treat unknown as disable (ie no consent given) but it is helpful to know that the user has not interacted with the legitimate interest UI yet so that you can subscribe to events and wait for legitimate interest information to be collected.
Example
Dart
1
// IAB vendors
2
await DidomiSdk.getUserLegitimateInterestStatusForVendor("1");
3
4
// Didomi vendors
5
await DidomiSdk.getUserLegitimateInterestStatusForVendor("google");
6
7
// Custom vendors (prefix vendor ID with c:)
8
await DidomiSdk.getUserLegitimateInterestStatusForVendor("c:custom-vendor-id");
Copied!

getUserLegitimateInterestStatusForVendorAndRequiredPurposes

Get the user legitimate interest status for a given vendor. We use the list of purposes declared for the vendor to make sure that it has allowed legitimate interest data processing for all of them. The required purposes are automatically setup for IAB or Didomi vendors and you must specify the required purposes for your custom vendors when configuring the tag.
Parameters
Name
Type
Description
vendorId
String
The ID of the vendor to check the user legitimate interest status for.
If you are checking an IAB vendor, pass the number as a String.
If you are checking a custom vendor, prefix your vendor ID with c:.
Returns
A ConsentStatus that indicates if the user has allowed legitimate interest data processing to the specific vendor and all the purposes that require legitimate interest for that vendor.
1
enum ConsentStatus { disable, enable, unknown }
Copied!
unknown is returned if the legitimate interest status is not known yet. From a GDPR perspective, you'll want to treat unknown as disable (ie no legitimate interest given) but it is helpful to know that the user has not interacted with the legitimate interest UI yet so that you can subscribe to events and wait for legitimate interest information to be collected.
Example
Dart
1
// IAB vendors
2
await DidomiSdk.getUserLegitimateInterestStatusForVendorAndRequiredPurposes("1");
3
4
// Didomi vendors
5
await DidomiSdk.getUserLegitimateInterestStatusForVendorAndRequiredPurposes("google");
6
7
// Custom vendors (prefix vendor ID with c:)
8
await DidomiSdk.getUserLegitimateInterestStatusForVendorAndRequiredPurposes("c:custom-vendor-id");
Copied!

getUserStatus

Get all the user consent status.
Throws
Type
Description
DidomiNotReadyException
Exception thrown when a method that requires the Didomi SDK to be ready is called before that. Developers can call this method within a try/catch or within a lambda expression passed into the onReady method.
Returns
A UserStatus object describing all the available and computed user information.
Parameter
Type
Description
purposes?.global?.disabled
List<String>?
Computed sets/lists of disabled IDs of purposes that have been chosen by the user regarding the consent or legitimate interest Legal Basis.
purposes?.global?.enabled
List<String>?
Computed sets/lists of enabled IDs of purposes that have been chosen by the user regarding the consent or legitimate interest Legal Basis. Purposes considered as essential will be part of the enabled IDs.
purposes?.consent?.disabled
List<String>?
Disabled IDs of purposes that have been explicitly chosen by the user regarding the consent Legal Basis.
purposes?.consent?.enabled
List<String>?
Enabled IDs of purposes that have been explicitly chosen by the user regarding the consent Legal Basis.
purposes?.legitimateInterest?.disabled
List<String>?
Disabled IDs of purposes that have been explicitly chosen by the user regarding the legitimate interest Legal Basis.
purposes?.legitimateInterest?.enabled
List<String>?
Enabled IDs of purposes that have been explicitly chosen by the user regarding the legitimate interest Legal Basis.
purposes?.essential
List<String>?
IDs of purposes that are considered essential.
vendors?.global?.disabled
List<String>?
Computed sets/lists of disabled IDs of vendors that have been chosen by the user regarding the consent or legitimate interest Legal Basis. This takes into account the consent and legitimate interest required purposes linked to vendors. When computing this property, essential purposes will be considered as enabled.
vendors?.global?.enabled
List<String>?
Computed sets/lists of enabled IDs of vendors that have been chosen by the user regarding the consent or legitimate interest Legal Basis. This takes into account the consent and legitimate interest required purposes linked to vendors. When computing this property, essential purposes will be considered as enabled.
vendors?.globalConsent?.disabled
List<String>?
Computed sets/lists of disabled IDs of vendors that have been chosen by the user regarding the consent Legal Basis. This takes into account the consent required purposes linked to vendors. When computing this property, essential purposes will be considered as enabled.
vendors?.globalConsent?.enabled
List<String>?
Computed sets/lists of enabled IDs of vendors that have been chosen by the user regarding the consent Legal Basis. This takes into account the consent required purposes linked to vendors. When computing this property, essential purposes will be considered as enabled.
vendors?.globalLegitimateInterest?.disabled
List<String>?
Computed sets/lists of disabled IDs of vendors that have been chosen by the user regarding the legitimate interest Legal Basis. This takes into account the legitimate interest required purposes linked to vendors. When computing this property, essential purposes will be considered as enabled.
vendors?.globalLegitimateInterest?.enabled
List<String>?
Computed sets/lists of enabled IDs of vendors that have been chosen by the user regarding the legitimate interest Legal Basis. This takes into account the legitimate interest required purposes linked to vendors. When computing this property, essential purposes will be considered as enabled.
vendors?.consent?.disabled
List<String>?
Disabled IDs of vendors that have been explicitly chosen by the user regarding the consent Legal Basis.
vendors?.consent?.enabled
List<String>?
Enabled IDs of vendors that have been explicitly chosen by the user regarding the consent Legal Basis.
vendors?.legitimateInterest?.disabled
List<String>?
Disabled IDs of vendors that have been explicitly chosen by the user regarding the legitimate interest Legal Basis.
vendors?.legitimateInterest?.enabled
List<String>?
Enabled IDs of vendors that have been explicitly chosen by the user regarding the legitimate interest Legal Basis.
userId
String?
Didomi user id.
created
String?
User choices creation date.
updated
String?
User choices update date.
consentString
String?
TFC consent as string.
additionalConsent
String?
Additional consent.
Example
Dart
1
UserStatus userStatus = await DidomiSdk.userStatus;
2
3
// Enabled consent ids for vendors
4
List<String>? enabledVendorsConsentIds = userStatus.vendors?.consent?.enabled;
Copied!

getUserStatusForVendor

Get the user consent and legitimate interest status for a given vendor.
Parameters
Name
Type
Description
vendorId
String
The ID of the vendor to check the user status for. If you are checking an IAB vendor, pass the number as a String. If you are checking a custom vendor, prefix your vendor ID with c:.
Returns
A ConsentStatus that indicates if the user has allowed both consent and legitimate interest data processing to the specific vendor.
1
enum ConsentStatus { disable, enable, unknown }
Copied!
If one of consent or legitimate interest data processing status is unknown or not allowed, disable will be returned. If both are allowed by the user, the function will return enable.
Example
Dart
1
// IAB vendors
2
await DidomiSdk.getUserStatusForVendor("1");
3
4
// Didomi vendors
5
await DidomiSdk.getUserStatusForVendor("google");
6
7
// Custom vendors (prefix vendor ID with c:)
8
await DidomiSdk.getUserStatusForVendor("c:custom-vendor-id");
Copied!

getVendor

Get a vendor based on its ID.
Requires SDK to be initialized
Yes.
Parameters
Name
Type
Description
vendorId
String
ID of the vendor we want to get.
Returns
Type
Description
Future<Vendor?>
A Vendor with ID vendorId found in the array of required vendors, or null.
Example
Dart
1
await DidomiSdk.getVendor("vendor-id");
Copied!

hideNotice

Hide the consent notice.
Parameters
No parameter.
Returns
Nothing
Example
Dart
1
await DidomiSdk.hideNotice();
Copied!

hidePreferences

Hide the preferences popup.
Parameters
No parameter.
Returns
Nothing
Example
Dart
1
await DidomiSdk.hidePreferences();
Copied!

initialize

Initialize the SDK. The initialization runs on a background thread to avoid blocking your UI. Use the onReady function to know when the initialization is done and the SDK is ready to be used.
Parameters
Name
Type
Optional
Description
apiKey
String
No
Your API key
localConfigurationPath
String
Yes
The path to your local config file in your assets/ folder. Defaults to didomi_config.json if null.
remoteConfigurationPath
String
Yes
The URL to a remote configuration file to load during initialization. When provided, the file at the URL will be downloaded and cached to be used instead of the local assets/didomi_config.json. If there is no Internet connection available and no previously cached file, the local file will be used as fallback.
providerId
String
Yes
Your provider ID (if any). A provider ID is assigned when you work with Didomi through a third-party. If are not sure if you have one, set this to null.
disableDidomiRemoteConfig
bool
Yes
Prevent the SDK from loading a remote configuration from the Didomi Console. Defaults to false (loading remote config).
Set this parameter to false to use a remote consent notice configuration loaded from the Didomi Console.
Set this parameter to true to disable loading configurations from the Didomi Console.
languageCode
String
Yes
Language in which the consent UI should be displayed. By default, the consent UI is displayed in the language configured in the device settings. This property allows you to override the default setting and specify a language to display the UI in. String containing the language code or the local code e.g.: "es", "fr", "en-US", "zh-HK", etc.
noticeId
String
Yes
Notice ID to load the configuration from. If provided, the SDK bypasses the app ID targeting and directly loads the configuration from the notice ID.
Returns
Nothing
Example
Dart
1
await DidomiSdk.initialize(
2
"<Your API key>",
3
noticeId: "<Your notice id>"
4
);
Copied!

isConsentRequired

Determine if consent is required for the user. This takes into account the location of the user and the configuration of the SDK:
  • If your app is configured to apply GDPR to all users then this function always returns true.
  • If your app is configured to apply GDPR to EU users only then this function returns true only if the user in the EU.
Parameters
No parameter.
Returns
Future<bool>
Example
Java
1
await DidomiSdk.isConsentRequired();
Copied!

isUserConsentStatusPartial

Determine if all consent information is available for the user.
This function returns true if and only if:
  • Consent is required for the user (ie the user is in the EU or your tag is configured to apply GDPR to all users)
  • At least one vendor is configured (if there is no vendor configured, this function always returns false as there is no consent to collect)
  • We miss consent information for some vendors or purposes
If there is at least one piece of consent information missing for a single vendor/purpose, this function will return true. The consent notice is usually displayed when this function returns true although there is no guarantee of the direct mapping between the two.
An important edge case is when you add new vendors or if configured vendors ask for new purposes: the consent notice will be displayed again and this function will return true until the user has given or denied consent. Vendors that already had consent before will still operate normally as we only recollect consent for additional vendors/purposes.
Parameters
No parameter.
Returns
Future<bool>
Example
Dart
1
await DidomiSdk.isUserConsentStatusPartial();
Copied!

isNoticeVisible

Check if the consent notice is currently displayed.
Parameters
No parameter.
Returns
Future<bool>
Example
Dart
1
await DidomiSdk.isNoticeVisible();
Copied!

isPreferencesVisible

Check if the preferences popup is currently displayed.
Parameters
No parameter.
Returns
Future<bool>
Example
Dart
1
await DidomiSdk.isPreferencesVisible();
Copied!

isReady

Check if the SDK is ready.
Parameters
No parameter.
Returns
Future<bool>
Example
Dart
1
await DidomiSdk.isReady();
Copied!

onError

Add a callback that will be called when the SDK initialization encounters an error. If the callback is added after the SDK initialization already failed, it will be called immediately.
Parameters
Name
Type
Description
callback
Function()
A callback to run when the SDK initialization encounters an error
Returns
Nothing
Example
Dart
1
DidomiSdk.onError(() =>
2
// The SDK has encountered an error
3
});
Copied!

onReady

Add a callback that will be called when the SDK is ready (ie fully initialized). If the callback is added after the SDK initialization, it will be called immediately.
All calls to other functions of this API must only be made in a callback to the ready event to make sure that the SDK is initialized before it is used.
Parameters
Name
Type
Description
callback
Function()
A callback to run when the SDK is ready
Returns
Nothing
Example
Dart
1
DidomiSdk.onReady(() =>
2
// The SDK is ready
3
});
Copied!

setLogLevel

Set the minimum level of messages to log. The SDK will not log messages under that level.
It uses a LogLevel object which maps log levels to corresponding values in iOS / Android native platforms.
1
enum LogLevel { verbose, debug, info, warn, error }
Copied!
For more information see
Parameters
Name
Type
Description
minLevel
LogLevel
Minimum level of messages to log.
Returns
Nothing
Example
Dart
1
DidomiSdk.setLogLevel(LogLevel.info);