Block Screenshots and Screen Recording in Flutter

Introduction
With the rise of data breaches and privacy concerns, securing sensitive content within mobile applications has become more crucial than ever. Apps that handle confidential information, such as financial apps, healthcare applications, and secure messaging platforms, must prevent unauthorized screen captures and recordings.
Flutter, by default, does not provide a built-in method to block screenshots or screen recording. However, by leveraging platform-specific implementations, we can enforce screen security efficiently.
This guide covers multiple approaches to prevent screenshots and screen recording in Flutter for Android and iOS, ensuring your app complies with security best practices.
If you’re looking for the best Flutter app development company for your mobile application then feel free to contact us at — support@flutterdevs.com.
Table of Contents:
Why Prevent Screenshots and Screen Recording?
Methods to Prevent Screenshots and Screen Recording in Flutter
1. Why Prevent Screenshots and Screen Recording?
Apps that handle sensitive information (e.g., finance, messaging, healthcare) need protection against unauthorized screenshots and recordings. Some key reasons include:
- Data Privacy: Prevent users from capturing sensitive content.
- Data Protection: Restrict users from capturing sensitive content. Compliance with Security Regulations: Some industries mandate strict privacy policies (e.g., HIPAA, GDPR, PCI DSS).
- Preventing Data Leaks: Screenshots of sensitive data can be shared easily, leading to security risks.
- User Trust and Experience: Enhancing security ensures user confidence in using your app for confidential tasks.
2. Methods to Prevent Screenshots and Screen Recording in Flutter
Blocking screenshots and screen recording requires platform-specific configurations because Flutter does not provide a direct implementation method. The solutions vary for Android and iOS:
1. Using screen_protector
Package (Flutter Plugin)
- Platform: Android & iOS
- Screenshots Blocked? Yes
- Screen Recording Blocked? No
- Implementation Complexity: Easy
Description:
- The
screen_protector
the plugin prevents screenshots on both Android and iOS. - It does not prevent screen recording, but can notify when recording starts on iOS.
- Simple and quick integration using a Flutter package.
- Ideal for basic security needs where blocking screenshots is the priority.
2. Using FLAG_SECURE
in Android
- Platform: Android
- Screenshots Blocked? Yes
- Screen Recording Blocked? Yes
- Implementation Complexity: Medium
Description:
- The
FLAG_SECURE
flag in Android prevents both screenshots and screen recording at the system level. - Ensures full security but may cause issues with certain accessibility features.
- Requires adding the flag at the Activity or Window level.
- Best for financial, streaming, and secure content apps.
3. Using Black Overlay Trick (Android)
- Platform: Android
- Screenshots Blocked? No
- Screen Recording Blocked? Yes
- Implementation Complexity: Advanced
Description:
- Instead of directly preventing recording, this method overlays a black transparent layer on top of the UI.
- When screen recording is detected, the app replaces the UI with a black screen.
- Requires more complex implementation but is useful when
FLAG_SECURE
is not an option.
4. Using UIScreen.capturedDidChangeNotification
in iOS
- Platform: iOS
- Screenshots Blocked? No
- Screen Recording Blocked? Yes (Detect Only)
- Implementation Complexity: Medium
Description:
- iOS does not allow blocking screen recording at the system level but provides an API to detect when recording starts.
- Developers can use
UIScreen.main.isCaptured
to check for active screen recording. - When recording is detected, the app can:
- Display a blur effect.
- Hide sensitive content.
- Show an alert.
- Suitable for privacy-sensitive apps where warning the user is enough.
5. Using Transparent Overlay to Prevent Screenshots (iOS Only)
- Platform: iOS
- Screenshots Blocked? Yes
- Screen Recording Blocked? No
- Implementation Complexity: Medium
Description:
- iOS does not provide a direct way to block screenshots.
- A common workaround is placing a transparent overlay over the screen.
- When a user takes a screenshot, the overlay appears in the screenshot instead of the actual content.
- Best for hiding sensitive content from screenshots but does not prevent screen recording.
Key Takeaways:
- The
screen_protector
package is the easiest option, but it does not block screen recording. - FLAG_SECURE in Android is the best solution for complete security.
- The Black Overlay Trick can be used for more advanced Android security.
- iOS allows only detection of screen recording, not blocking.
- Using a transparent overlay in iOS is a good workaround to block screenshots.
Each method has its own advantages and limitations, and the best approach depends on your app’s security requirements.

3. Code Implementation:
Method 1: Using screen_protector
Package (Easy Approach)
The screen_protector
package provides a straightforward way to block screenshots and blur the app preview in the recent apps screen. However, it does not prevent screen recording.
Step 1: Install the Package
Add the dependency in pubspec.yaml
:
dependencies:
screen_protector: ^1.4.2+1
Run:
flutter pub get
Step 2: Implement Screen Protection Service
Create a new file:
📂 lib/services/screen_protection_service.dart
import 'package:screen_protector/screen_protector.dart';
class ScreenProtectionService {
/// Enable screenshot protection and blur recent apps preview
static Future<void> enableProtection() async {
try {
await ScreenProtector.preventScreenshotOn();
await ScreenProtector.protectDataLeakageOn(); // Blurs recent apps preview
print("Screen protection enabled");
} catch (e) {
print("Error enabling screen protection: $e");
}
}
/// Disable screenshot protection
static Future<void> disableProtection() async {
try {
await ScreenProtector.preventScreenshotOff();
await ScreenProtector.protectDataLeakageOff();
print("Screen protection disabled");
} catch (e) {
print("Error disabling screen protection: $e");
}
}
}
Step 3: Apply the Protection in main.dart
import 'package:flutter/material.dart';
import 'services/screen_protection_service.dart';
void main() {
runApp(const MyApp());
ScreenProtectionService.enableProtection();
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(title: const Text("Screen Protection Demo")),
body: Center(
child: ElevatedButton(
onPressed: () async {
await ScreenProtectionService.disableProtection();
},
child: const Text("Disable Protection"),
),
),
),
);
}
}
Prevents screenshots and blurs recent app preview
Does NOT block screen recording
Method 2: Using FLAG_SECURE
in Android (Best for Android)
The FLAG_SECURE
flag is the most effective way to prevent both screenshots and screen recordings on Android devices.
Step 1: Modify MainActivity.kt
📂 android/app/src/main/kotlin/com/example/yourapp/MainActivity.kt
import android.os.Bundle
import io.flutter.embedding.android.FlutterActivity
import android.view.WindowManager
class MainActivity: FlutterActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
window.setFlags(
WindowManager.LayoutParams.FLAG_SECURE,
WindowManager.LayoutParams.FLAG_SECURE
)
}
}
Prevents screenshots and screen recording on Android
Cannot be bypassed easily
Method 3: Detect Screen Recording on iOS
iOS does not provide a built-in method to block screen recording, but we can detect when a recording is in progress and take action.
Step 1: Modify AppDelegate.swift
📂 ios/Runner/AppDelegate.swift
import UIKit
import Flutter
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
NotificationCenter.default.addObserver(
self,
selector: #selector(screenRecordingChanged),
name: UIScreen.capturedDidChangeNotification,
object: nil
)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
@objc func screenRecordingChanged() {
if UIScreen.main.isCaptured {
print("Screen recording detected! Taking necessary action.")
// Hide sensitive UI elements or log out user
}
}
}
Detects if screen recording is active on iOS
Cannot block screen recording automatically
4. Limitations
While blocking screenshots and screen recordings is a strong first step in protecting user data, developers must be aware of the inherent limitations of these methods and plan accordingly.
1. Cannot Prevent External Cameras
Even if your app successfully blocks all digital capture methods (screenshots, screen recordings), there’s no technical way to stop someone from using another physical device (like a phone or DSLR) to record your app screen. This is a physical-world limitation and needs non-technical mitigation strategies like watermarking or access restrictions.
2. Some Screen Recorders Can Bypass Restrictions
Certain third-party apps or system-level tools, especially on rooted Android or jailbroken iOS devices, can circumvent security flags like FLAG_SECURE
. Although rare, this poses a potential loophole in your protection strategy. Developers targeting high-security apps (banking, fintech, confidential tools) should be cautious and consider app integrity checks (e.g., SafetyNet, App Attest).
3. Performance Considerations
Polling for screen capture states (like using UIScreen.main.isCaptured
in iOS) frequently in real-time can introduce performance overhead. Developers should consider:
- Listening to notification-based events instead of polling.
- Throttling UI updates on detection.
- Offloading detection logic to isolated components or background services.
4. Practical Workarounds
When traditional screen-blocking mechanisms fall short, here are some developer-centric solutions:
- Watermarking Sensitive Screens
Embed user information (username, timestamp) or generic watermarks to deter unauthorized sharing of screen recordings or screenshots. - AI-Powered Real-time Detection (Experimental)
Train a model to detect unusual on-screen behavior or pixel duplication that resembles screen capture. - Blur or Mask Sensitive Content
Temporarily replace confidential areas with placeholders when suspicious behavior is detected.
5. Future Scope
The security landscape continues to evolve. Developers should anticipate future threats and opportunities by staying proactive.
1. AI-based External Camera Detection
In the near future, we might see machine learning models integrated into apps to analyze real-time camera feed reflections or light changes to detect potential external recording attempts — though privacy regulations could affect such capabilities.
2. Blockchain for Screen Data Integrity
For applications dealing with legal, financial, or intellectual property content, integrating blockchain can ensure that:
- Access logs are immutable.
- Any screen interaction (including screenshots) can be cryptographically traced and verified. This approach is not about prevention, but post-event accountability.
3. Evolving Flutter Plugins
As the Flutter ecosystem matures, we can expect:
- Plugins that offer cross-platform UI masking.
- Built-in screen detection hooks.
- Integrations with native security APIs (like Android SafetyNet or iOS App Attest).
Flutter’s open-source nature and rapidly growing community make this space promising.
6. Conclusion:
Developer Takeaways
Preventing screenshots and screen recordings in Flutter is an essential aspect of app security, particularly for apps that deal with:
- Financial data
- Private conversations
- Sensitive documents
- Media rights protection (e.g., streaming platforms)
While no single method provides absolute protection, combining tools like:
screen_protector
pluginFLAG_SECURE
flag- iOS detection APIs
- UI-level overlays
…offers a multi-layered defense.
As developers, it’s our responsibility to:
- Understand platform limitations
- Stay updated on OS-level changes
- Proactively add additional security layers such as authentication, encryption, watermarking, and access logging
Security is not a feature — it’s a process.
With the right strategies and ongoing vigilance, developers can greatly reduce the risks of data leaks and protect user trust.
❤ ❤ Thanks for reading this article ❤❤
If I got something wrong? Let me know in the comments. I would love to improve.
Clap 👏 If this article helps you.
Feel free to connect with us:
And read more articles from FlutterDevs.com.
FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire Flutter developer for your cross-platform Flutter mobile app project hourly or full-time as per your requirement! For any flutter-related queries, you can connect with us on Facebook, GitHub, Twitter, and LinkedIn.
We welcome feedback and hope that you share what you’re working on using #FlutterDevs. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences.
