Anti Screenshot

A Flutter package that prevents screenshots and screen recordings on both Android and iOS platforms. This package provides three different protection modes to ensure your app's content remains secure.

Features

  • 🛡️ Three protection modes:

    • Black Mode: Captured screen appears completely black
    • Blur Mode: Captured screen appears blurred
    • Block Mode: Completely disables screenshots and screen recording
  • 📱 Platform-specific implementations:

    • Android: Uses FLAG_SECURE and monitors Media Projection API
    • iOS: Uses UIScreen.isCaptured and secure window features

Installation

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

dependencies:
  anti_screenshot: ^1.0.5

Usage

Wrap your app or specific widgets with AntiScreenshot:

import 'package:anti_screenshot/anti_screenshot.dart';

void main() {
  runApp(
    AntiScreenshot(
      mode: ProtectionMode.black, // Options: black, blur, block
      child: MyApp(),
    ),
  );
}

Protection Modes

  1. Black Mode (ProtectionMode.black):

    • When a screenshot is attempted, the screen appears completely black in the captured image
    • Best for maximum privacy while maintaining app functionality
  2. Blur Mode (ProtectionMode.blur):

    • When a screenshot is attempted, the screen appears blurred in the captured image
    • Provides a visual indication that the content is protected
  3. Block Mode (ProtectionMode.block):

    • Completely prevents screenshots and screen recordings
    • Most secure option, but may affect some system functionalities

Platform Support

Platform Support
Android
iOS

Implementation Details

Android

  • Uses WindowManager.LayoutParams.FLAG_SECURE to prevent screenshots
  • Monitors Media Projection API for screen recording attempts
  • Handles Accessibility Services to prevent unauthorized captures

iOS

  • Uses UIScreen.main.isCaptured to detect screen recording
  • Implements secure window features to prevent unauthorized access
  • Monitors screenshot notifications via UIApplication.userDidTakeScreenshotNotification

Example

Check out the example folder for a complete demo application.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

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

Libraries

anti_screenshot