-1

In this case I will disable the screen capture on certain pages. which contains documents that are vulnerable to misuse. Does Flutter support that?

this code main.dart:

  Future<void> _toggleScreenShot() async {

    if (_isSecureScreen == true) {
      await FlutterWindowManager
          .addFlags(FlutterWindowManager.FLAG_SECURE);
      print("Tidak bisa ");
    } else {
      await FlutterWindowManager
          .clearFlags(FlutterWindowManager.FLAG_SECURE);
      print("Tidak bisa ");
    }

    setState(() {
      _isSecureScreen = !_isSecureScreen;
    });
  }

this code mainactivity.kt :

@Override
fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);

}

1 Answers1

0

Check this package flutter_windowmanager

In our App, we only wished to disable screenshots for specific screens, rather than across the entire application lifecycle. This can now be accomplished by simply calling:

await FlutterWindowManager.addFlags(FlutterWindowManager.FLAG_SECURE);

for the relevant screen.

Add this to your dependencies in pubspec.yaml

flutter_windowmanager: ^0.0.2
Android_id
  • 1,521
  • 1
  • 15
  • 33
  • I've used these depedencies. but it doesn't work. @Android_id – indriyanto Nugroho Feb 17 '21 at 13:05
  • Please paste your code of what have you tried – Android_id Feb 17 '21 at 13:08
  • ' Future _toggleScreenShot() async { if (_isSecureScreen == true) { await FlutterWindowManager .addFlags(FlutterWindowManager.FLAG_SECURE); print("Tidak bisa "); } else { await FlutterWindowManager .clearFlags(FlutterWindowManager.FLAG_SECURE); print("Tidak bisa "); } setState(() { _isSecureScreen = !_isSecureScreen; }); }' – indriyanto Nugroho Feb 17 '21 at 13:17