Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save prongbang/bf9d3dff135ed300b87a2322cb032023 to your computer and use it in GitHub Desktop.
Save prongbang/bf9d3dff135ed300b87a2322cb032023 to your computer and use it in GitHub Desktop.
void disableScreenRecording({bool enabled = false}) async {
// Get the Android device.
final device = await FlutterDevice.current;
// Run the "adb shell settings put secure allow_screen_captures" command.
final result = await device.run('adb', [
'shell',
'settings',
'put',
'secure',
'allow_screen_captures',
enabled ? '1' : '0',
]);
// Check the result.
if (result.exitCode != 0) {
throw Exception('Failed to disable screen recording.');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment