I've got an education flutter iOS app. and I want to prevent users to take screenshots or screen records on a specific screen and how to make it
CodePudding user response:
The simplest way to do this is to use a flutter package called flutter_windowmanager
Works only for Android, not for IOS!
First import its latest version in pubspec.yaml file of your Flutter project and run pub get. Then add the below code inside the widget's initState() method for which you want to disable screenshot and screen recording.
Future<void> secureScreen() async {
await FlutterWindowManager.addFlags(FlutterWindowManager.FLAG_SECURE);
}
@override
void initState() {
secureScreen();
super.initState();
}
@override
void dispose(){
super.dispose();
await FlutterWindowManager.clearFlags(FlutterWindowManager.FLAG_SECURE);
}
If you want to make your whole app screenshot disable just call securescreen() method (defined above) inside your main() function in main.dart file.
CodePudding user response:
Use this if you don't want users to take screenshots in your app. flutter_windowmanager
By using this package, you can add many more functionality like blur app when its in background, force full screen, dismiss keyguard.
Read the dicumentation for more info.