'How to prevent user from recording screen in Flutter?

I'd like to know if there is any way to detect if the screen is getting recorded while my Flutter App is active.

My objective is to pause the video if any app/system is recoding screen while my app is active. Is this possible in Flutter?



Solution 1:[1]

You cannot automatically pause the video, instead what you could do (on Android) is adding the SECURE flag (Read more here). This will prevent the user from taking a screenshot of your app, and in the case there is a screen recording active while your app is in use, this will not show any content.

The flutter_windowmanager package is what you are looking for.

import 'package:flutter_windowmanager/flutter_windowmanager.dart';
    

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    FlutterWindowManager.addFlags(FlutterWindowManager.FLAG_SECURE); //This
    return MaterialApp(
      title: 'My App',
      theme: ThemeData(
        primarySwatch: Colors.red,
      ),
      home: const Home(),
    );
  }
}
    

enter image description here

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 Dani3le_