Prevent Screenshot and Video Recording in Flutter

Gulshan Yadav
2 min readMay 12, 2020

Introduction

In this article, you will learn how you can prevent users from taking screenshots or recording videos of the app.

To achieve this, there are two methods which I know. 1st method is useful when you want to protect any particular screen of the app. Using the 2nd method you can protect the whole app irrespective of any particular screen.

So, let’s start with the methods.

Method-1:

In this method, we’ll use the flutter_windowmanager package.

So, define this package inside pubspec.yaml file.

flutter_windowmanager: ^0.0.1+1

Now, get dependencies using

flutter pub get

You have to add a few lines of code in your StatefulWidget. You need to call a method of FlutterWindowManager using await and async. I have added that method inside secureScreen() function and then called secureScreen() inside initState().

Future<void> secureScreen() async {await FlutterWindowManager.addFlags(FlutterWindowManager.FLAG_SECURE); }@override
void initState() {
secureScreen();

--

--

Gulshan Yadav

Freelancer - Flutter | Android | Blockchain | NodeJs | Technical Writer | Open Source Contributor | LinkedIn — https://www.linkedin.com/in/mrgulshanyadav