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.
Mount the widget
Section titled “Mount the widget”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, ), ); }}Handle authenticated vs. guest users
Section titled “Handle authenticated vs. guest users”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, ), ); }}Add navigation
Section titled “Add navigation”Link to the Rights Center from your app’s settings or account screen:
// Using NavigatorListTile( leading: const Icon(Icons.privacy_tip_outlined), title: const Text('Privacy & Data Rights'), onTap: () => Navigator.push( context, MaterialPageRoute(builder: (_) => const RightsCenterScreen()), ),),
// Using GoRouterGoRoute( path: '/rights-center', builder: (context, state) => const RightsCenterScreen(),),context.push('/rights-center');Widget props
Section titled “Widget props”| Prop | Type | Description |
|---|---|---|
userId * | String | Authenticated user ID. Must match the ID used when consent was recorded. |
apiKey * | String | API key from the platform dashboard. |
organizationId * | String | Your org ID — sent on every request. |
apiUrl * | String | SDK base URL: https://trukit-dev.truconsent.io |
assetId * | String | Asset UUID from the platform dashboard. |
DPDPA rights surfaced
Section titled “DPDPA rights surfaced”| Right | DPDPA reference |
|---|---|
| Access personal data | Section 11 |
| Correction and erasure | Section 12 |
| Grievance redressal | Section 13 |
| Withdraw consent | Section 6 |
| Nominate a representative | Section 14 |