getRefusedObjectives static method

Future<List<String>?> getRefusedObjectives()

Gets the list of refused objectives asynchronously.

This method returns the objectives that the user has explicitly refused consent for. These objectives should not be used for data processing.

Returns a Future<List<String>?> containing the refused objective IDs, or null if none exist

Implementation

static Future<List<String>?> getRefusedObjectives() {
  final Completer<List<String>?> completer = Completer<List<String>?>();
  BlueConicPlatform.instance.getRefusedObjectives().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 refused objectives: $e'),
          );
        }
      }
    } else {
      completer.completeError(Exception(result.error ?? 'Unknown error'));
    }
  });
  return completer.future;
}