secure_screen_plugin

Very Good Ventures Very Good Ventures

Developed with 💙 by Very Good Ventures 🦄

coverage style: very good analysis License: MIT

A Flutter plugin that provides secure screen functionality to prevent screenshots and screen recording on Android and iOS platforms.

Features

  • 🔒 Enable/disable secure screen on Android and iOS
  • 📱 Prevents screenshots and screen recording
  • 🎯 Simple and easy-to-use API
  • 🏗️ Built with federated plugin architecture

Installation

Add secure_screen_plugin to your pubspec.yaml:

dependencies:
  secure_screen_plugin: ^0.1.0

Then run:

flutter pub get

Usage

Import the package

import 'package:secure_screen_plugin/secure_screen_plugin.dart';

Enable secure screen

To prevent screenshots and screen recording:

await enableSecureScreen();

Disable secure screen

To allow screenshots and screen recording again:

await disableSecureScreen();

Example

import 'package:flutter/material.dart';
import 'package:secure_screen_plugin/secure_screen_plugin.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool _isSecure = false;

  Future<void> _toggleSecureScreen() async {
    if (_isSecure) {
      await disableSecureScreen();
    } else {
      await enableSecureScreen();
    }
    setState(() {
      _isSecure = !_isSecure;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Secure Screen Example'),
        ),
        body: Center(
          child: ElevatedButton(
            onPressed: _toggleSecureScreen,
            child: Text(_isSecure ? 'Disable Secure Screen' : 'Enable Secure Screen'),
          ),
        ),
      ),
    );
  }
}

Platform Support

  • ✅ Android
  • ✅ iOS
  • ❌ Web (not supported)
  • ❌ macOS (not supported)
  • ❌ Windows (not supported)
  • ❌ Linux (not supported)

Notes

  • On Android, this plugin uses FLAG_SECURE to prevent screenshots and screen recording.
  • On iOS, this plugin uses UIScreen.capturedDidChangeNotification to detect screen recording attempts.
  • The secure screen feature is automatically disabled when the app goes to the background.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.