Prevent Video Recording & Screenshot

Flutter

  1. Add flutter_windowmanager to pubspec.yaml.
  2. 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

  1. Locate MainActivity file and import Android.view.windowmanager.layoutparams.
  2. Add the code below.
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.oCreate(savedInstanceState);

  getWindow().addFlags(LayoutParams.FLAG_SECURE);
}


ios

  1. 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