Search packages, repositories and app categories

Package detailsv1.5.3

screen_protector

Safe Data Leakage via Application Background Screenshot and Prevent Screenshot for Android and iOS.

AndroidiOS
30-day downloads
128K
Likes
326
Pub points
150

Install package

flutter pub add screen_protector

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

Screen Protector is a Flutter package that safeguards sensitive data by preventing unauthorized screenshots when the app runs in the background on both Android and iOS. It leverages platform-specific mechanisms to detect and block screenshot attempts, reducing the risk of data leakage. Ideal for apps handling confidential information such as banking, healthcare, or secure messaging, it enhances security without requiring complex implementation. The package integrates seamlessly with Flutter projects via a simple pub add command.

Use cases

  • Protecting sensitive user data in financial apps
  • Preventing screen capture in healthcare applications
  • Securing confidential communications
  • Blocking screenshots during app backgrounding
  • Enhancing privacy in enterprise mobile solutions

Key features

  • Prevents background screenshots on Android and iOS
  • Uses native platform APIs for reliable detection
  • Minimal integration effort with Flutter
  • Supports both Android and iOS platforms
  • Automatic screenshot blocking when app is minimized

Suitable for

  • Apps handling sensitive personal information
  • Enterprise-grade security requirements
  • Privacy-focused applications
  • Mobile banking and payment platforms
  • Secure messaging and communication tools

Considerations

  • May not work on all devices due to OS restrictions
  • Requires proper permission handling
  • Limited effectiveness against physical camera capture
  • Potential impact on user experience if overused
  • Not a substitute for end-to-end encryption

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

screen_protector

Safe Data Leakage via Application Background Screenshot and Prevent Screenshot for Android and iOS.

Important (Breaking Change)

Versions 1.4.4 through 1.4.13 may cause crashes on some devices. Please use version 1.4.3 or earlier, or upgrade to version 1.5.1 or later.

Feature

Import
import 'package:screen_protector/screen_protector.dart';
iOS
Protect Data Leakage Background Screenshot
  • Protect data leakage with image
await ScreenProtector.protectDataLeakageWithImage('LaunchImage');
  • Protect data leakage with color ON
await ScreenProtector.protectDataLeakageWithColor(Colors.white);
  • Protect data leakage with color OFF
await ScreenProtector.protectDataLeakageWithColorOff();
  • Protect data leakage with blur ON
await ScreenProtector.protectDataLeakageWithBlur();
  • Protect data leakage with blur OFF
await ScreenProtector.protectDataLeakageWithBlurOff();
Prevent Screenshot
  • ON
await ScreenProtector.preventScreenshotOn();
  • OFF
await ScreenProtector.preventScreenshotOff();
Check Screen Recording
final isRecording = await ScreenProtector.isRecording();
Android
Protect Data Leakage Background Screenshot and Prevent Screenshot
  • ON
await ScreenProtector.protectDataLeakageOn();

or

await ScreenProtector.preventScreenshotOn();
  • OFF
await ScreenProtector.protectDataLeakageOff();

or

await ScreenProtector.preventScreenshotOff();
Protect Data Leakage for Android 12+ (Optional)

https://github.com/prongbang/screen-protector

import com.prongbang.screenprotect.AndroidScreenProtector

class MainActivity : FlutterFragmentActivity() {

    private val screenProtector by lazy { AndroidScreenProtector.newInstance(this) }

    // For Android 12+
    override fun onWindowFocusChanged(hasFocus: Boolean) {
        super.onWindowFocusChanged(hasFocus)
        screenProtector.process(hasFocus.not())
    }
}

Usage

Android
  • Protect Data Leakage Background Screenshot and Prevent Screenshot.
import 'package:screen_protector/screen_protector.dart';

class _PreventScreenshotPageState extends State<MyApp> {

  void _preventScreenshotOn() async => await ScreenProtector.protectDataLeakageOn();

  void _protectDataLeakageOff() async => await ScreenProtector.protectDataLeakageOff();

  @override
  void initState() {
    _preventScreenshotOn();
    super.initState();
  }

  @override
  void dispose() {
    _protectDataLeakageOff();
    super.dispose();
  }

}
iOS
  • Prevent Screenshot
import 'package:screen_protector/screen_protector.dart';

class _PreventScreenshotPageState extends State<MyApp> {

  void _preventScreenshotOn() async => await ScreenProtector.preventScreenshotOn();

  void _preventScreenshotOff() async => await ScreenProtector.preventScreenshotOff();

  @override
  void initState() {
    _preventScreenshotOn();
    super.initState();
  }

  @override
  void dispose() {
    _preventScreenshotOff();
    super.dispose();
  }

}
  • Protect data leakage with color
import 'package:screen_protector/screen_protector.dart';

class _ProtectDataLeakagePageState extends State<MyApp> {

  void _protectDataLeakageWithColor() async => await ScreenProtector.protectDataLeakageWithColor(Colors.white);

  @override
  void initState() {
    _protectDataLeakageWithColor();
    super.initState();
  }

}
  • Protect data leakage with image

image01.png

import 'package:screen_protector/screen_protector.dart';

class _ProtectDataLeakagePageState extends State<MyApp> {

  void _protectDataLeakageWithImage() async => await ScreenProtector.protectDataLeakageWithImage('LaunchImage');

  @override
  void initState() {
    _protectDataLeakageWithImage();
    super.initState();
  }

}
  • Protect data leakage with blur
import 'package:screen_protector/screen_protector.dart';

class _ProtectDataLeakagePageState extends State<MyApp> {

  void _protectDataLeakageWithBlur() async => await ScreenProtector.protectDataLeakageWithBlur();

  @override
  void initState() {
    _protectDataLeakageWithBlur();
    super.initState();
  }

}

💖 Support the Project

If you find this package helpful, please consider supporting it:

"Buy Me A Coffee"

Categories

Source repository

Projects using this package