preventScreenshotsGlobally method

  1. @override
Future<void> preventScreenshotsGlobally()
override

Prevents screenshots globally across the app using native platform methods.

This method invokes the preventScreenshotsGlobally method on the native platform to set security flags for the entire app, blocking screenshots and screen recording. If an error occurs, a PlatformException is thrown with a descriptive error message.

Implementation

@override
Future<void> preventScreenshotsGlobally() async {
  try {
    await methodChannel.invokeMethod('preventScreenshotsGlobally');
  } on PlatformException catch (e) {
    throw 'Failed to globally prevent screenshots: ${e.message}';
  }
}