flutter_privacy_shield 0.0.1 copy "flutter_privacy_shield: ^0.0.1" to clipboard
flutter_privacy_shield: ^0.0.1 copied to clipboard

Privacy-focused utilities for data anonymization and GDPR compliance

Flutter Privacy Shield #

Pub Version License Flutter Dart

A comprehensive privacy-focused utility package for Flutter applications, providing data anonymization, GDPR compliance tools, and privacy protection utilities. Built with cross-platform support and WASM compatibility.

Features #

🔒 Privacy Protection

  • Data anonymization utilities
  • Sensitive data detection and masking
  • Privacy score calculation
  • Audit logging for compliance

📋 GDPR Compliance

  • Consent management
  • Data retention policies
  • Processing log generation
  • Rights request handling

🌐 Cross-Platform Support

  • ✅ iOS
  • ✅ Android
  • ✅ Web (with WASM support)
  • ✅ Windows
  • ✅ macOS
  • ✅ Linux

Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  flutter_privacy_shield: ^0.0.1

Then run:

flutter pub get

Quick Start #

Basic Usage #

import 'package:flutter_privacy_shield/flutter_privacy_shield.dart';

void main() {
  // Create a privacy shield instance
  final privacyShield = PrivacyShield();
  
  // Process data with privacy protection
  final userData = {
    'name': 'John Doe',
    'email': 'john@example.com',
    'password': 'secret123',
    'ssn': '123-45-6789',
  };
  
  final processedData = privacyShield.processData(
    userData,
    purpose: 'user_registration',
    consentStatus: ConsentStatus.granted,
  );
  
  print('Processed data: $processedData');
}

Data Anonymization #

// Anonymize sensitive strings
final anonymizedEmail = Anonymizer.anonymizeEmail('user@example.com');
// Result: 'u***r@example.com'

final anonymizedPhone = Anonymizer.anonymizePhone('123-456-7890');
// Result: '12******90'

final anonymizedCard = Anonymizer.anonymizeCreditCard('1234-5678-9012-3456');
// Result: '************3456'

// Anonymize JSON data
final userData = {
  'name': 'John Doe',
  'password': 'secret123',
  'token': 'abc123',
};

final anonymizedData = Anonymizer.anonymizeJson(userData);
// Result: password and token fields are masked

GDPR Compliance #

// Check consent status
final hasConsent = GdprCompliance.hasConsent(userPreferences);

// Record user consent
final updatedPreferences = GdprCompliance.recordConsent(
  userPreferences,
  ConsentStatus.granted,
  purpose: 'analytics',
);

// Check data retention
final shouldRetain = GdprCompliance.shouldRetainData(
  dataTimestamp,
  RetentionPolicy.shortTerm,
  null,
);

// Validate processing compliance
final isCompliant = GdprCompliance.isProcessingCompliant(
  consentStatus: ConsentStatus.granted,
  purpose: 'analytics',
  isDataMinimized: true,
  hasRetentionPolicy: true,
);

Privacy Utilities #

// Generate privacy-safe identifiers
final privacyId = PrivacyUtils.generatePrivacyId('user@example.com');

// Check for sensitive data
final hasSensitiveData = PrivacyUtils.containsSensitiveData(text);

// Sanitize text
final sanitizedText = PrivacyUtils.sanitizeText(text);

// Calculate privacy score
final privacyScore = PrivacyUtils.calculatePrivacyScore(
  isAnonymized: true,
  hasConsent: true,
  isMinimized: true,
  hasRetentionPolicy: true,
  isEncrypted: false,
  hasAuditTrail: true,
);

Advanced Configuration #

Custom Privacy Shield Configuration #

final customConfig = {
  'anonymization_enabled': true,
  'gdpr_compliance_enabled': true,
  'audit_logging_enabled': true,
  'default_retention_policy': RetentionPolicy.longTerm,
  'sensitive_fields': ['password', 'token', 'secret', 'key', 'ssn'],
};

final privacyShield = PrivacyShield(config: customConfig);

Field-Specific Anonymization #

final data = {
  'name': 'John Doe',
  'email': 'john@example.com',
  'phone': '123-456-7890',
  'ssn': '123-45-6789',
};

final anonymizedData = privacyShield.anonymizeFields(
  data,
  ['ssn', 'phone'],
  mask: '#',
);

Privacy Score #

The package provides a comprehensive privacy scoring system (0-100) based on:

  • Data Anonymization (25 points)
  • Consent Management (25 points)
  • Data Minimization (20 points)
  • Retention Policies (15 points)
  • Encryption (10 points)
  • Audit Trails (5 points)

Audit Logging #

All privacy operations are automatically logged for compliance:

// Get audit log
final auditLog = privacyShield.getAuditLog();

// Clear audit log
privacyShield.clearAuditLog();

Platform Support #

This package is designed to work seamlessly across all Flutter platforms:

  • Mobile: iOS and Android with native performance
  • Web: Full WASM compatibility for web applications
  • Desktop: Windows, macOS, and Linux support
  • Cross-platform: Consistent API across all platforms

Testing #

Run the test suite to ensure everything works correctly:

flutter test

The package includes comprehensive tests covering:

  • Data anonymization functions
  • GDPR compliance utilities
  • Privacy utilities
  • Integration scenarios

Contributing #

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

License #

This project is licensed under the MIT License - see the LICENSE file for details.

Support #

If you encounter any issues or have questions, please:

  1. Check the documentation
  2. Search existing issues
  3. Create a new issue with detailed information

Roadmap #

  • ❌ Enhanced encryption utilities
  • ❌ Machine learning-based sensitive data detection
  • ❌ Integration with privacy frameworks
  • ❌ Performance optimizations
  • ❌ Additional compliance standards support

Built with ❤️ for the Flutter community

Maintained by Dhia Bechattaoui

2
likes
160
points
12
downloads

Publisher

verified publisherbechattaoui.dev

Weekly Downloads

Privacy-focused utilities for data anonymization and GDPR compliance

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_privacy_shield