Download StackFood Multi Restaurant, Food Delivery App with Laravel Admin and Restaurant Panel Buy Full App on $79
Download FlutKit - Flutter UI Kit Most beautiful Flutter UI Kit with 20+ Full App, 450+ Screens. Buy Full Kit on $39
Download Fluxstore Multi Vendor WooCommerce/Dokan Plugin compatible WordPress eCommerce Flutter App. Buy Full App on $79

How to Disable Screenshot Capture/Screen Recording in Flutter

In this example, we are going to make an app that prevents screenshot capture or screenshot recording its app interface. We have used the window manager Flutter package to disable screenshot capture and screen recordings.

First, you need to add flutter_windowmanager package in your project by adding the following line lines in pubspec.yaml file.

dependencies:
  flutter:
    sdk: flutter
  flutter_windowmanager: ^0.2.0

Import [ackage in the script:

import 'package:flutter_windowmanager/flutter_windowmanager.dart';

How to Disable Screenshot Capture/Screenshot Recording

await FlutterWindowManager.addFlags(FlutterWindowManager.FLAG_SECURE);
//enables secure mode for app, disables screenshot, screen recording

Full Code Example:

import 'package:flutter/material.dart';
import 'package:flutter_windowmanager/flutter_windowmanager.dart';
void main() {
  runApp(
    MaterialApp( 
      home: MyApp(),
    )
  );
}

class MyApp extends StatefulWidget{
  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

  @override
  void initState() {
    Future.delayed(Duration.zero, () async { //to run async code in initState
       await FlutterWindowManager.addFlags(FlutterWindowManager.FLAG_SECURE);
       //enables secure mode for app, disables screenshot, screen recording
    });

    super.initState();
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
          body: Container(
             //your app content here
          )
    );
  }
}

Output Screenshot on your try to take screenshot or screen recording:

In this way, you can force prevent screenshot capture and screen recording for the Flutter app.

No any Comments on this Article


Please Wait...