screenshot_detect_plugin_flutter 0.0.1 copy "screenshot_detect_plugin_flutter: ^0.0.1" to clipboard
screenshot_detect_plugin_flutter: ^0.0.1 copied to clipboard

A simple package to detect user screenshots and get path images.

screenshot_detect_plugin_flutter #

A simple package to detect user screenshots and get path images. You can from image link to social sharing. Hope to help you.

Source


Getting Started #

Android

  • Add to AndroidManifest
  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
    android:maxSdkVersion="32" />
  <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
  • For android 10 add requestLegacyExternalStorage to
  <activity
      ....
      android:requestLegacyExternalStorage="true">
  </activity>

IOS

  • Add NSPhotoLibraryUsageDescription to Info.plit
    <key>NSPhotoLibraryUsageDescription</key>
    <string>This app requires access to the photo library.</string>

You can to check and request permission checkPermission work to android, ios coming soon bro.

    Future<void> _checkPermission() async {
    _screenshotDetect.checkPermission().then((isGranted) {
      if (isGranted == null || !isGranted) {
        _screenshotDetect.requestPermission();
      }
    });
  }

Create Stream of Screenshot stream and listen call back

    Future<void> _listenScreenShot() async {
    _stream = _screenshotDetect.screenShotStream();

    _stream.listen((String? path) {
      print("It is a path screenshot!\n $path");
    }).onError((error) {
      print("It is somethings wrong: \n $error");
    });
  }

Full example:

class _MyAppState extends State<MyApp> {
  final ScreenshotDetect _screenshotDetect = ScreenshotDetect();
  late Stream<String?> _stream;

  @override
  void initState() {
    super.initState();
    _checkPermission();
    _listenScreenShot();
  }

  Future<void> _checkPermission() async {
    _screenshotDetect.checkPermission().then((isGranted) {
      if (isGranted == null || !isGranted) {
        _screenshotDetect.requestPermission();
      }
    });
  }

  Future<void> _listenScreenShot() async {
    _stream = _screenshotDetect.screenShotStream();

    _stream.listen((String? path) {
      print("It is a path screenshot!\n $path");
    }).onError((error) {
      print("It is somethings wrong: \n $error");
    });
  }

...
2
likes
0
points
7
downloads

Publisher

unverified uploader

Weekly Downloads

A simple package to detect user screenshots and get path images.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on screenshot_detect_plugin_flutter

Packages that implement screenshot_detect_plugin_flutter