getConsentedObjectives static method
Gets the list of consented objectives asynchronously.
Objectives represent different purposes for data processing (e.g., analytics, marketing, personalization). This method returns the objectives the user has given consent for.
Returns a Future<List<String>?> containing the consented objective IDs,
or null if none exist
Implementation
static Future<List<String>?> getConsentedObjectives() {
final Completer<List<String>?> completer = Completer<List<String>?>();
BlueConicPlatform.instance.getConsentedObjectives().then((result) {
if (result.success) {
final data = result.data;
if (data == null) {
completer.complete(null);
} else {
try {
final List<String> converted = (data as List)
.map((e) => e.toString())
.toList();
completer.complete(converted);
} catch (e) {
completer.completeError(
Exception('Failed to convert consented objectives: $e'),
);
}
}
} else {
completer.completeError(Exception(result.error ?? 'Unknown error'));
}
});
return completer.future;
}