enableScreenshotBlocking method
Enables screenshot blocking on supported platforms.
On Android, this prevents screenshots while the PIN input is visible. On iOS, screenshot blocking is not supported by the system.
Returns true if screenshot blocking was enabled, false otherwise.
Implementation
Future<bool> enableScreenshotBlocking() async {
if (kIsWeb) {
return false;
}
try {
if (Platform.isAndroid) {
// Use MethodChannel to communicate with native Android code
// This requires platform-specific implementation
const platform = MethodChannel('pin_plus_keyboard/security');
await platform.invokeMethod('enableScreenshotBlocking');
return true;
} else if (Platform.isIOS) {
// iOS doesn't support programmatic screenshot blocking
// Apps can use UIApplication.shared.isIdleTimerDisabled but that's
// not the same as blocking screenshots
debugPrint('Screenshot blocking not supported on iOS');
return false;
}
} catch (e) {
debugPrint('SecurityService: Error enabling screenshot blocking: $e');
}
return false;
}