anti_screenshot_guard 1.0.0 copy "anti_screenshot_guard: ^1.0.0" to clipboard
anti_screenshot_guard: ^1.0.0 copied to clipboard

A Flutter plugin to prevent screenshots and detect screenshot events on Android and iOS.

Anti Screenshot Guard #

pub package likes popularity points license

A Flutter plugin to prevent screenshots and detect screenshot events on Android and iOS.

Platform Support #

Platform Screenshot Prevention Screenshot Detection
Android ✅ FLAG_SECURE ❌ Not needed
iOS ❌ Not possible ✅ Notification

Android Behavior #

  • Uses WindowManager.LayoutParams.FLAG_SECURE to prevent screenshots and screen recordings
  • Prevents recent apps preview capture
  • Can be enabled/disabled dynamically per screen

iOS Behavior #

  • Screenshot prevention is NOT possible due to Apple platform limitations
  • Detects screenshot events using UIApplication.userDidTakeScreenshotNotification
  • Allows UI mitigation (blur, overlay, callback) when screenshot is detected

Installation #

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

dependencies:
  anti_screenshot_guard: ^1.0.0

Usage #

Basic API #

import 'package:anti_screenshot_guard/anti_screenshot_guard.dart';

// Enable screenshot protection
await AntiScreenshotGuard.enable();

// Disable screenshot protection
await AntiScreenshotGuard.disable();

// Check if protection is enabled
bool enabled = await AntiScreenshotGuard.isEnabled;

// Listen for screenshot events
AntiScreenshotGuard.addScreenshotListener(() {
  print('Screenshot detected!');
});

// Remove listener
AntiScreenshotGuard.removeScreenshotListener(callback);

SecureScreen Widget #

SecureScreen(
  enableProtection: true,
  blurOnScreenshot: true,
  onScreenshot: () {
    // Handle screenshot event
    showDialog(
      context: context,
      builder: (context) => AlertDialog(
        title: Text('Screenshot Detected'),
        content: Text('Please do not take screenshots of sensitive content.'),
      ),
    );
  },
  child: Container(
    child: Text('Sensitive content here'),
  ),
)

iOS Limitations Warning #

⚠️ Important: On iOS, it is impossible to prevent screenshots due to platform restrictions imposed by Apple. Attempting to block screenshots would violate Apple's App Store guidelines and may result in app rejection.

The plugin provides detection capabilities on iOS so you can:

  • Show warnings to users
  • Blur sensitive content temporarily
  • Log screenshot attempts
  • Implement other mitigation strategies

Example #

See the example directory for a complete Flutter app demonstrating the plugin's features.

Author #

Panca Nugraha

Support the author ❤️ #

Saweria:
https://saweria.co/pancanugraha

Buy Me a Coffee:
https://buymeacoffee.com/pancanugraha

0
likes
0
points
117
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin to prevent screenshots and detect screenshot events on Android and iOS.

Repository (GitHub)
View/report issues

Documentation

Documentation

License

unknown (license)

Dependencies

flutter

More

Packages that depend on anti_screenshot_guard

Packages that implement anti_screenshot_guard