Flutter privacy
Record consent, request a data export, and delete the account from a Flutter app.
On this page
core.privacy (PrivacyClient) records consent, starts data exports, and starts account deletion. Status:
fixture-tested. Concepts: Consent and privacy. Endpoints:
Identity API.
Consent
final record = await core.privacy.setConsent(
'optional_analytics',
granted: true,
policyVersion: '<your-policy-version>',
); // ConsentRecord: purpose, status ('granted' | 'withdrawn'), policyVersion, recordedAtPurposes (consentPurposes): optional_analytics, marketing_push, marketing_email, marketing_whatsapp,
personalization. setConsent sends POST /v1/privacy/consent with {purpose, status, policy_version}. It is
retried with the same key within one call.
Recording consent does not change SDK behaviour by itself. For analytics, keep the client gate in step:
Future<void> setAnalyticsConsent(AppCore core, bool allowed) async {
await core.privacy.setConsent('optional_analytics', granted: allowed, policyVersion: '<your-policy-version>');
if (allowed) {
core.analytics.consentGranted = true;
} else {
core.analytics.revokeConsent(); // also deletes unsent events
}
}Warning
Not yet enabled: reading consent back. The contract has no consent read endpoint, so the SDK cannot restore
the user's choices after reinstall or on a new device. Store the choice locally and set
core.analytics.consentGranted after each AppCore.init.
Data export
var job = await core.privacy.requestExport(); // POST /v1/privacy/export → Job (202)
job = await core.privacy.job(job.id); // GET /v1/jobs/{id}; job.status, job.isTerminal, job.resultRefThe export is a durable server job. The SDK does not download the result. How the user receives the export is decided by the backend's privacy workflow.
Account deletion
final job = await core.deleteAccount(); // DELETE /v1/privacy/account → Job, then wipes the local sessioncore.deleteAccount() asks for the durable deletion job and then clears the session and all per-user local state
(entitlements, inbox, remote config, queued analytics). Prefer it to privacy.requestAccountDeletion(), which only
makes the request.
Deleting the account does not cancel store subscriptions. Apple and Google bill the user until they cancel in
the store. Before confirming, tell the user so and link to Subscription.managementUrl from
core.commerce.subscriptions(). That link comes from the server; never build it yourself.
The reference app's confirmation dialog (examples/flutter-reference/lib/screens/settings.dart) shows the wording.