flutter_screen_data_leakage_protector 1.1.0 copy "flutter_screen_data_leakage_protector: ^1.1.0" to clipboard
flutter_screen_data_leakage_protector: ^1.1.0 copied to clipboard

A Flutter plugin to prevent sensitive data leakage by obscuring the screen (overlaying a black screen) when the application is in the background or app switcher. Supports Android and iOS.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_screen_data_leakage_protector/flutter_screen_data_leakage_protector.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Leakage Protector Demo',
      theme: ThemeData(
        useMaterial3: true,
        colorScheme: ColorScheme.fromSeed(
          seedColor: Colors.deepPurple,
          brightness: Brightness.dark,
        ),
      ),
      home: const HomeScreen(),
    );
  }
}

class HomeScreen extends StatefulWidget {
  const HomeScreen({super.key});

  @override
  State<HomeScreen> createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {
  @override
  void initState() {
    super.initState();
    // Initialize the protector with a custom image overlay
    FlutterScreenDataLeakageProtector.applyDataLeakageWithConfig(
      overlayImage: 'privacy_overlay',
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: CustomScrollView(
        slivers: [
          SliverAppBar.large(title: const Text('Security Shield')),
          SliverToBoxAdapter(
            child: Padding(
              padding: const EdgeInsets.all(16.0),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  _buildInstructionCard(context),
                  const SizedBox(height: 24),
                  const Text(
                    'SENSITIVE DATA PREVIEW',
                    style: TextStyle(
                      fontSize: 12,
                      fontWeight: FontWeight.bold,
                      letterSpacing: 1.2,
                      color: Colors.grey,
                    ),
                  ),
                  const SizedBox(height: 12),
                  _buildBalanceCard(context),
                  const SizedBox(height: 16),
                  _buildTransactionList(context),
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }

  Widget _buildInstructionCard(BuildContext context) {
    return Card(
      elevation: 0,
      color: Theme.of(
        context,
      ).colorScheme.surfaceContainerHighest.withOpacity(0.3),
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(20),
        side: BorderSide(color: Theme.of(context).colorScheme.outlineVariant),
      ),
      child: Padding(
        padding: const EdgeInsets.all(20.0),
        child: Column(
          children: [
            Row(
              children: [
                Icon(
                  Icons.shield_rounded,
                  color: Theme.of(context).colorScheme.primary,
                  size: 32,
                ),
                const SizedBox(width: 12),
                const Expanded(
                  child: Text(
                    'Verification Steps',
                    style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
                  ),
                ),
              ],
            ),
            const SizedBox(height: 16),
            _buildStep(context, '1', 'Minimize the app or open App Switcher.'),
            _buildStep(
              context,
              '2',
              'Check if the screen preview is obscured by the custom Privacy Shield image.',
            ),
            _buildStep(
              context,
              '3',
              'Return to app - the screen should automatically restore.',
            ),
          ],
        ),
      ),
    );
  }

  Widget _buildStep(BuildContext context, String number, String text) {
    return Padding(
      padding: const EdgeInsets.only(bottom: 8.0),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Container(
            padding: const EdgeInsets.all(6),
            decoration: BoxDecoration(
              color: Theme.of(context).colorScheme.primary,
              shape: BoxShape.circle,
            ),
            child: Text(
              number,
              style: const TextStyle(
                fontSize: 10,
                fontWeight: FontWeight.bold,
                color: Colors.white,
              ),
            ),
          ),
          const SizedBox(width: 12),
          Expanded(child: Text(text)),
        ],
      ),
    );
  }

  Widget _buildBalanceCard(BuildContext context) {
    return Container(
      width: double.infinity,
      padding: const EdgeInsets.all(24),
      decoration: BoxDecoration(
        gradient: LinearGradient(
          colors: [
            Theme.of(context).colorScheme.primary,
            Theme.of(context).colorScheme.tertiary,
          ],
          begin: Alignment.topLeft,
          end: Alignment.bottomRight,
        ),
        borderRadius: BorderRadius.circular(24),
        boxShadow: [
          BoxShadow(
            color: Theme.of(context).colorScheme.primary.withOpacity(0.3),
            blurRadius: 20,
            offset: const Offset(0, 10),
          ),
        ],
      ),
      child: const Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            'Total Balance',
            style: TextStyle(color: Colors.white70, fontSize: 16),
          ),
          SizedBox(height: 8),
          Text(
            '\$ 1,284,560.00',
            style: TextStyle(
              color: Colors.white,
              fontSize: 32,
              fontWeight: FontWeight.bold,
              letterSpacing: 1,
            ),
          ),
          SizedBox(height: 20),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Text(
                '**** **** **** 8888',
                style: TextStyle(color: Colors.white70, letterSpacing: 2),
              ),
              Icon(Icons.credit_card, color: Colors.white70),
            ],
          ),
        ],
      ),
    );
  }

  Widget _buildTransactionList(BuildContext context) {
    final transactions = [
      ('Apple Store', '-\$ 999.00', 'Today'),
      ('Transfer from Dad', '+\$ 5,000.00', 'Yesterday'),
      ('Starbucks', '-\$ 12.50', 'Feb 1'),
    ];

    return Column(
      children: transactions.map((t) {
        return ListTile(
          contentPadding: EdgeInsets.zero,
          leading: CircleAvatar(
            backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
            child: Icon(
              t.$1.contains('Transfer')
                  ? Icons.arrow_downward
                  : Icons.shopping_bag,
              size: 20,
              color: Theme.of(context).colorScheme.onSecondaryContainer,
            ),
          ),
          title: Text(
            t.$1,
            style: const TextStyle(fontWeight: FontWeight.w600),
          ),
          subtitle: Text(t.$3),
          trailing: Text(
            t.$2,
            style: TextStyle(
              fontWeight: FontWeight.bold,
              color: t.$2.startsWith('+') ? Colors.greenAccent : null,
            ),
          ),
        );
      }).toList(),
    );
  }
}
0
likes
150
points
132
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin to prevent sensitive data leakage by obscuring the screen (overlaying a black screen) when the application is in the background or app switcher. Supports Android and iOS.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flutter_screen_data_leakage_protector

Packages that implement flutter_screen_data_leakage_protector