prevent_app_screen 0.1.2
prevent_app_screen: ^0.1.2 copied to clipboard
A Flutter plugin to prevent screenshots and screen recordings on Android, iOS, macOS, Windows, Linux, and Web.
๐ก๏ธ Prevent App Screen #
A powerful, high-performance Flutter plugin designed to protect your application from Screenshots and Screen Recordings. Ideal for banking apps, streaming platforms, and privacy-focused tools.
โจ Key Features #
- ๐ Global Protection: Secure your entire app with a single line of code.
- ๐ป Cross-Platform: Full support for Android, iOS, macOS, Windows, Linux, and Web.
- ๐ฑ Screen-Level Security: Dynamic protection that activates/deactivates per route.
- ๐ซ๏ธ Granular Masking: Blur or hide specific UI components (e.g., Credit Card numbers).
- ๐ App Switcher Blur: Automatically hides app content in multitasking views.
- ๐ฅ Recording Detection: Real-time detection and response to screen recordings and mirroring.
๐ Getting Started #
Installation #
Add the dependency to your pubspec.yaml:
dependencies:
prevent_app_screen: ^0.1.2
Basic Initialization #
For the best security, initialize the plugin in your main() method to protect the entire application from the start.
void main() {
WidgetsFlutterBinding.ensureInitialized();
// Enable protection globally
PreventAppScreen.initialize(true);
runApp(const MyApp());
}
๐ Protection Levels #
1๏ธโฃ Full Screen Protection #
Wrap specific screens to block screenshots and recording ONLY while that specific page is visible. Useful for login or profile pages.
@override
Widget build(BuildContext context) {
return FullScreenProtection(
prevent: true,
child: Scaffold(
appBar: AppBar(title: Text("Sensitive Info")),
body: MyPrivateContent(),
),
);
}
2๏ธโฃ Granular Widget Masking #
Use SpecificWidgetProtection to protect specific UI elements. You can choose between a Blur effect or a custom Placeholder.
SpecificWidgetProtection(
protectWindow: true, // Blocks the ENTIRE screenshot/recording while visible
blurAmount: 15.0, // Intensity of the blur
placeholder: BlackBox(), // Optional: Show a custom widget instead of blurring
child: CreditCardWidget(),
)
| Parameter | Type | Description |
|---|---|---|
protectWindow |
bool |
Proactive: Secure the whole window as long as this widget is on screen. |
prevent |
bool |
Reactive: Auto-blur the widget if a screen recording starts (Mobile). |
forceBlur |
bool |
Manual: Always blur the widget regardless of capture status. |
placeholder |
Widget? |
Display this widget instead of applying a blur effect. |
๐ Platform Support & Details #
| Feature | Android | iOS | macOS | Windows | Linux | Web |
|---|---|---|---|---|---|---|
| Screenshot Blocking | โ | โ | โ | โ | โ ๏ธยน | โ ๏ธยฒ |
| Recording Prevention | โ | โ | โ | โ | โ ๏ธยน | โ ๏ธยฒ |
| App Switcher Blur | โ | โ | N/A | N/A | N/A | N/A |
| Capture Detection | โ | โ | โ | โ | โ | โ |
Platform Notes #
- ยน Linux: Screenshot prevention is compositor-dependent (X11/Wayland). The plugin provides a success response but actual blocking varies by environment.
- ยฒ Web: Browsers do not provide APIs to block screenshots. The plugin applies
user-select: noneto the body as a deterrent. - macOS/Windows: Uses native window affinity APIs to prevent capture by other applications.
๐ License #
This project is licensed under the MIT License - see the LICENSE file for details.