screenshot_callback_plus 1.0.0 copy "screenshot_callback_plus: ^1.0.0" to clipboard
screenshot_callback_plus: ^1.0.0 copied to clipboard

Flutter plugin that allows you to detect screenshot and execute callback functions.

example/lib/main.dart

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

void main() => runApp(const MyApp());

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

  @override
  MyAppState createState() => MyAppState();
}

class MyAppState extends State<MyApp> {
  late ScreenshotCallbackPlus screenshotCallback;

  String text = "Ready..";

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

    init();
  }

  void init() async {
    await initScreenshotCallback();
  }

  //It must be created after permission is granted.
  Future<void> initScreenshotCallback() async {
    screenshotCallback = ScreenshotCallbackPlus();

    screenshotCallback.addListener(() {
      setState(() {
        text = "Screenshot callback Fired!";
      });
    });

    screenshotCallback.addListener(() {
      debugPrint("We can add multiple listeners ");
    });
  }

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Detect Screenshot Callback Example'),
        ),
        body: Center(
          child: Text(text,
              style: const TextStyle(
                fontWeight: FontWeight.bold,
              )),
        ),
      ),
    );
  }
}
0
likes
130
pub points
67%
popularity

Publisher

verified publishersolusibejo.com

Flutter plugin that allows you to detect screenshot and execute callback functions.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, flutter_web_plugins, plugin_platform_interface

More

Packages that depend on screenshot_callback_plus