'how to disable screen capture in flutter programming language?
In this case I will disable the screen capture on certain pages. which contains documents that are vulnerable to misuse. Does Flutter support that?
this code main.dart:
Future<void> _toggleScreenShot() async {
if (_isSecureScreen == true) {
await FlutterWindowManager
.addFlags(FlutterWindowManager.FLAG_SECURE);
print("Tidak bisa ");
} else {
await FlutterWindowManager
.clearFlags(FlutterWindowManager.FLAG_SECURE);
print("Tidak bisa ");
}
setState(() {
_isSecureScreen = !_isSecureScreen;
});
}
this code mainactivity.kt :
@Override
fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
}
Solution 1:[1]
Check this package flutter_windowmanager
In our App, we only wished to disable screenshots for specific screens, rather than across the entire application lifecycle. This can now be accomplished by simply calling:
await FlutterWindowManager.addFlags(FlutterWindowManager.FLAG_SECURE);
for the relevant screen.
Add this to your dependencies in pubspec.yaml
flutter_windowmanager: ^0.0.2
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Android_id |