Prevent Video Recording & Screenshot
Flutter
- Add flutter_windowmanager to pubspec.yaml.
- Add the code below. If needed to apply on complete app, then call it in main.dart file.
Future<void> secureScreen() async {
await FlutterWindowManager.addFlags(FlutterWindowManager.FLAG_SECURE);
}
@override
void initState() {
secureScreen();
super.initState();
}
Android
- Locate MainActivity file and import Android.view.windowmanager.layoutparams.
- Add the code below.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.oCreate(savedInstanceState);
getWindow().addFlags(LayoutParams.FLAG_SECURE);
}
ios
- Locate Appdelegate.m file and add the code below.
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)LaunchOptions {
[GeneratedPluginRegistrant registerWithRegistry:self];
//Override point for customization after application launch.
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
- (void)applicationWillResignActive:(UIApplication *)application {
self.window.hidden = YES;
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
self.window.hidden = NO;
}
@end