Skip to content

Rights Center — Flutter

The NativeRightCenter widget provides a pre-built UI for DPDPA data subject rights — letting users access, correct, or delete their personal data and withdraw consent.

Create a dedicated screen and add NativeRightCenter as its body:

import 'package:flutter/material.dart';
import 'package:truconsent_consent_notice_flutter/truconsent_consent_banner_flutter.dart';
import '../../config/truconsent_config.dart';
class RightsCenterScreen extends StatelessWidget {
final String userId;
const RightsCenterScreen({super.key, required this.userId});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Privacy & Data Rights')),
body: NativeRightCenter(
userId: userId,
apiKey: TruConsentConfig.apiKey,
organizationId: TruConsentConfig.organizationId,
apiUrl: TruConsentConfig.apiBaseUrl,
assetId: TruConsentConfig.assetId,
),
);
}
}

Resolve the user ID before rendering. Use the authenticated user ID when logged in, or a stable guest UUID otherwise:

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:truconsent_consent_notice_flutter/truconsent_consent_banner_flutter.dart';
import '../../providers/auth_provider.dart';
import '../../utils/guest_id_utils.dart';
import '../../config/truconsent_config.dart';
class RightsCenterScreen extends ConsumerStatefulWidget {
const RightsCenterScreen({super.key});
@override
ConsumerState<RightsCenterScreen> createState() => _RightsCenterScreenState();
}
class _RightsCenterScreenState extends ConsumerState<RightsCenterScreen> {
String? _userId;
bool _isLoading = true;
@override
void initState() {
super.initState();
_loadUserId();
}
Future<void> _loadUserId() async {
final user = ref.read(authProvider);
final id = user != null ? user.id : await GuestIdUtils.getGuestId();
setState(() {
_userId = id;
_isLoading = false;
});
}
@override
Widget build(BuildContext context) {
if (_isLoading) {
return const Scaffold(body: Center(child: CircularProgressIndicator()));
}
if (_userId == null) {
return Scaffold(
appBar: AppBar(title: const Text('Privacy & Data Rights')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text('Unable to load Rights Center'),
const SizedBox(height: 16),
ElevatedButton(
onPressed: () {
setState(() => _isLoading = true);
_loadUserId();
},
child: const Text('Retry'),
),
],
),
),
);
}
return Scaffold(
appBar: AppBar(title: const Text('Privacy & Data Rights')),
body: NativeRightCenter(
userId: _userId!,
apiKey: TruConsentConfig.apiKey,
organizationId: TruConsentConfig.organizationId,
apiUrl: TruConsentConfig.apiBaseUrl,
assetId: TruConsentConfig.assetId,
),
);
}
}

Link to the Rights Center from your app’s settings or account screen:

// Using Navigator
ListTile(
leading: const Icon(Icons.privacy_tip_outlined),
title: const Text('Privacy & Data Rights'),
onTap: () => Navigator.push(
context,
MaterialPageRoute(builder: (_) => const RightsCenterScreen()),
),
),
// Using GoRouter
GoRoute(
path: '/rights-center',
builder: (context, state) => const RightsCenterScreen(),
),
context.push('/rights-center');
* Required
PropTypeDescription
userId *StringAuthenticated user ID. Must match the ID used when consent was recorded.
apiKey *StringAPI key from the platform dashboard.
organizationId *StringYour org ID — sent on every request.
apiUrl *StringSDK base URL: https://trukit-dev.truconsent.io
assetId *StringAsset UUID from the platform dashboard.
RightDPDPA reference
Access personal dataSection 11
Correction and erasureSection 12
Grievance redressalSection 13
Withdraw consentSection 6
Nominate a representativeSection 14