preventScreenshotsAndRecording method

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

Prevents both screenshots and screen recording for specific screens using native platform methods.

This method invokes the preventScreenshots method on the native platform. It is intended for restricting screenshots on specific screens rather than the entire app. If an error occurs, a PlatformException is thrown with a descriptive error message.

Implementation

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