updateConsentForm static method

Future<GdprResult> updateConsentForm({
  1. List<String>? testIdentifiers,
})

Allows user to update GDPR consent.

Implementation

static Future<GdprResult> updateConsentForm(
    {List<String>? testIdentifiers}) async {
  final completer = Completer<GdprResult>();

  final params = ConsentRequestParameters(
      consentDebugSettings:
          ConsentDebugSettings(testIdentifiers: testIdentifiers));

  ConsentInformation.instance.requestConsentInfoUpdate(params, () async {
    if (await ConsentInformation.instance.isConsentFormAvailable()) {
      ConsentForm.loadConsentForm((consentForm) {
        consentForm.show((formError) async {
          if (formError != null) {
            _logFormError(formError);
            completer.complete(GdprResult.error(formError));
          } else {
            completer.complete(GdprResult.status(await getConsentStatus()));
          }
        });
      }, (formError) {
        _logFormError(formError);
        completer.complete(GdprResult.error(formError));
      });
    } else {
      final formError = FormError(
          errorCode: 0,
          message: 'Consent Form is not available at the moment');
      _logFormError(formError);
      completer.complete(GdprResult.error(formError));
    }
  }, (formError) {
    _logFormError(formError);
    completer.complete(GdprResult.error(formError));
  });

  return completer.future;
}