Skip to content

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

License

Notifications You must be signed in to change notification settings

skiprco/screen_protector

 
 

Repository files navigation

screen_protector

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

Feature

iOS

  • Protect Data Leakage Background Screenshot
await ScreenProtector.protectDataLeakageWithColor(Colors.white);
await ScreenProtector.protectDataLeakageWithBlur();
await ScreenProtector.protectDataLeakageWithImage('LaunchImage');
await ScreenProtector.protectDataLeakageOff()
  • Prevent Screenshot
await ScreenProtector.preventScreenshotOn();
await ScreenProtector.preventScreenshotOff();

Android

  • Protect Data Leakage Background Screenshot and Prevent Screenshot
await ScreenProtector.protectDataLeakageOn();
await ScreenProtector.preventScreenshotOn();

Usage

  • Protect Data Leakage Background Screenshot and Prevent Screenshot for Android.
class _MyAppState extends LifecycleState<MyApp> {
  @override
  void initState() {
    // For iOS only.
    _protectDataLeakageWithColor();
    super.initState();
  }

  @override
  void onResumed() {
    // For Android only.
    _protectDataLeakageOff();
    super.onResumed();
  }

  @override
  void onPaused() {
    // For Android only.
    _protectDataLeakageOn();
    super.onPaused();
  }

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: const MainPage(),
      routes: <String, WidgetBuilder>{
        '/prevent-screenshot': (_) => const PreventScreenshotPage(),
      },
    );
  }
}
  • Prevent Screenshot for iOS
class _PreventScreenshotPageState extends State<PreventScreenshotPage> {
  @override
  void initState() {
    // For iOS only.
    _preventScreenshotOn();
    super.initState();
  }

  @override
  void dispose() {
    // For iOS only.
    _preventScreenshotOff();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        title: const Text('Prevent Screenshot'),
      ),
      body: const Center(
        child: Text('Secure Screen'),
      ),
    );
  }

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

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Dart 55.0%
  • Swift 22.7%
  • Kotlin 9.9%
  • Ruby 9.4%
  • Objective-C 2.9%
  • Makefile 0.1%