allowScreenshots method

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

Allows screenshots for the current screen only using native platform methods.

This method invokes the allowScreenshots method on the native platform, clearing security flags for the current screen. This enables screenshots and screen recording specifically on this screen, if previously restricted. If an error occurs, a PlatformException is thrown with a descriptive error message.

Implementation

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