isUserUnderGdpr static method

Future<bool> isUserUnderGdpr()

Wether the user is under the GDPR.

Useful for offering options to update GDPR settings.

This method initializes AsyncPreferences internally, is is an expensive call.

Implementation

static Future<bool> isUserUnderGdpr() async {
  // Initialize AsyncPreferences and checks if the IABTCF_gdprApplies
  // parameter is 1, if it is the user is under the GDPR,
  // any other value could be interpreted as not under the GDPR
  final preferences = AsyncPreferences();
  final userIsUnderGdpr = await preferences.getInt('IABTCF_gdprApplies') == 1;
  _log('userIsUnderGdpr: $userIsUnderGdpr');
  return userIsUnderGdpr;
}