changePrivacyPreferences method

Future<bool> changePrivacyPreferences()

Opens the privacy preferences screen for the user to manage consent. Returns a Future

Implementation

Future<bool> changePrivacyPreferences() async {
  final completer = Completer<bool>();

  ConsentInformation.instance.requestConsentInfoUpdate(
    ConsentRequestParameters(),
    () async {
      if (await ConsentInformation.instance.isConsentFormAvailable()) {
        ConsentForm.loadConsentForm(
          (consentForm) {
            consentForm.show((formError) async {
              // Continue with initialization after consent form is shown.
              await _initialize();
              completer.complete(true);
              log('');
            });
          },
          (formError) {
            // Handle error loading consent form.
            completer.complete(false);
          },
        );
      } else {
        completer.complete(false);
      }
    },
    (error) {
      // Handle error during consent info update.
      completer.complete(false);
    },
  );
  return completer.future;
}