Prohibit screenshots

Gautier Siclon
Gautier Siclon

Co-founder, Apparence.io

Flutter tips · Published on

Why Control Screenshots in Your Flutter App?

Sometimes, app developers want to control how users interact with content, especially when it comes to sharing. You might want to protect private information, prevent specific content from being directly shared, or ensure branding consistency. For example, some apps automatically add their logo to screenshots when they are shared on social media, while others block screenshots entirely for security reasons.

How to Prohibit Screenshots in a Flutter App

Step 1: Add the no_screenshot Plugin

The first thing you need to do is add the no_screenshot plugin to your Flutter project's pubspec.yaml file. This plugin gives you the tools to manage screenshot functionality.

Step 2: Disable Screenshots

To stop users from taking screenshots or recording their screen, call the noScreenshot.screenshotOff() method. It's a good idea to put this call inside a try-catch block to handle any errors. Also, consider only enabling this feature in production mode, not during development (kDebugMode).

/// This function disables screenshots and screen recording for security or privacy.
Future<void> _disableScreenshots() async {
  if (kDebugMode) { // Check if we are in debug mode
    return; // Don't disable screenshots during debugging
  }
  try {
    await noScreenshot.screenshotOff(); // Turn off screenshots
  } catch (e) {
    debugPrint('Failed to disable screenshots: $e'); // Log any errors
  }
}

Step 3: Re-enable Screenshots

It's very important to turn screenshots back on (noScreenshot.screenshotOn()) when the user leaves the sensitive page or when the widget is no longer needed. This ensures that users can take screenshots normally in other parts of your app or on other screens.

/// This function re-enables screenshots when leaving the sensitive screen.
Future<void> _enableScreenshots() async {
  try {
    await noScreenshot.screenshotOn(); // Turn on screenshots
  } catch (e) {
    debugPrint('Failed to enable screenshots: $e'); // Log any errors
  }
}

Important Reminder

Always make sure to re-enable screenshots once the user has moved away from the content you wanted to protect. Forgetting to do this can lead to a frustrating experience for your users.

Save 3 months of work

One command. Pick your modules. Firebase or Supabase auto-configured. Start building what matters.

kickstarter for flutter apps

Frequently Asked Questions

Why would I want to disable screenshots in my Flutter app?

You might want to protect sensitive user data, prevent unauthorized sharing of private content, or maintain your app's branding when content is shared on social media.

How do I disable screenshots in a Flutter app?

You can use the `no_screenshot` plugin. After installing it, call `noScreenshot.screenshotOff()` at the appropriate time to disable screenshots.

Is it important to re-enable screenshots?

Yes, it's crucial to re-enable screenshots using `noScreenshot.screenshotOn()` once the user navigates away from the sensitive screen. This ensures a normal user experience elsewhere in the app.

Should I disable screenshots during app development?

The provided code suggests checking for `kDebugMode` and skipping the disable function during development. This is usually a good idea for easier testing and debugging of your app.

Read more
You may also be interested in
Made by ApparenceKit logo
ApparenceKit is a flutter start kit | template generator tool by Apparence.io © 2026.
All rights reserved