flutter_screenshot_detect 0.1.0 copy "flutter_screenshot_detect: ^0.1.0" to clipboard
flutter_screenshot_detect: ^0.1.0 copied to clipboard

A Flutter plugin to detect screenshots

example/lib/main.dart

// example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:flutter_screenshot_detect/screenshot_detect.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: ScreenshotDetectDemo(),
    );
  }
}

class ScreenshotDetectDemo extends StatefulWidget {
  @override
  _ScreenshotDetectDemoState createState() => _ScreenshotDetectDemoState();
}

class _ScreenshotDetectDemoState extends State<ScreenshotDetectDemo> {
  final ScreenshotDetect _detector = ScreenshotDetect();
  final List<ScreenshotEvent> _events = [];

  @override
  void initState() {
    super.initState();
    _detector.startListening((event) {
      setState(() {
        _events.insert(0, event);
      });
    });
  }

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Screenshot Detector Example'),
      ),
      body: Column(
        children: [
          Padding(
            padding: const EdgeInsets.all(16.0),
            child: Text(
              'Screenshots detected: ${_events.length}',
              style: Theme.of(context).textTheme.headlineSmall,
            ),
          ),
          const Padding(
            padding: EdgeInsets.all(16.0),
            child: Text(
              'Take a screenshot to test the detector!',
              style: TextStyle(fontSize: 16),
            ),
          ),
          Expanded(
            child: ListView.builder(
              itemCount: _events.length,
              itemBuilder: (context, index) {
                final event = _events[index];
                return ListTile(
                  title: Text('Method: ${event.method}'),
                  subtitle: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Text('Time: ${event.timestamp}'),
                      if (event.path != null) Text('Path: ${event.path}'),
                    ],
                  ),
                );
              },
            ),
          ),
        ],
      ),
    );
  }
}
7
likes
0
points
1.09k
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin to detect screenshots

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flutter_screenshot_detect