zo_screenshot
Zo Screenshot is a Flutter plugin that enhances privacy by preventing screenshots and screen recording. It also lets you capture screenshots of specific widgets, making it perfect for secure apps that still need custom capture features.
✅ Key Features
✔️ Enable or disable screenshot capturing
✔️ Detect and stream screenshot events in real time
✔️ Secure sensitive pages like login, payments, and chat
✔️ Prevent screen recording on protected screens
✔️ Capture widget and share share you widgets in image format
🔐 Protect your Flutter app from unauthorized screenshots today!
Table of contents
Getting started
First, add zo_screenshot as a dependency in your pubspec.yaml file
dependencies:
flutter:
sdk: flutter
zo_screenshot : ^[version]
Import the package
import 'package:zo_screenshot/zo_screenshot.dart';
Usage
Disabling ScreenShot
final _zoScreenshotPlugin = ZoScreenshot();
_zoScreenshotPlugin.disableScreenShot();
Enabling Screenshot
final _zoScreenshotPlugin = ZoScreenshot();
_zoScreenshotPlugin.enableScreenshot();
Listen To Screenshot Event
final _zoScreenshotPlugin = ZoScreenshot();
_zoScreenshotPlugin.startScreenshotListner(
screenShotcallback: () {
print("Screenshot taken");
},
);
Convert Widget to shareable images
// create Capture Area Controller
ZoCaptureAreaController _areaController = ZoCaptureAreaController();
ZoCaptureArea(
controller: _areaController,
child: InkWell(
onTap: () {
_areaController.captureAndShare();
},
child: Container(
width: 150,
height: 150,
alignment: Alignment.center,
color: Colors.red,
child: const Text("Click"),
),
),
)
Secure Specific Routes
Financial apps like Google Pay (GPay) prevent sensitive screens from being recorded or captured. You can implement similar security measures in your app by blocking screenshots and screen recordings on specific routes. The approach depends on your navigation style—whether you're using named routes or class-based navigation.
For Named Route
return MaterialApp(
navigatorObservers: [
ZoNavigatorObserver(
navigationStyle: NavigationStyle.namedRoute,
secureNamedRouteList: ["/secureRoute"],
),
],
routes: {
"/secureRoute": (context) => const SecureRoute(),
"/nonSecureRoute": (context) => NonSecure(),
},
home: Scaffold(
appBar: AppBar(
centerTitle: true,
title: const Text('Zo Screenshot Example'),
),
body: Example(),
),
);
For Class Route
return MaterialApp(
navigatorObservers: [
ZoNavigatorObserver(
navigationStyle: NavigationStyle.classRoute,
secureClassRouteList: [SecureRoute],
),
],
home: Scaffold(
appBar: AppBar(
centerTitle: true,
title: const Text('Zo Screenshot Example'),
),
body: Example(),
),
);
Show Preview While App is in Background
Wrap with ZoScreenShotWrapper
ZoScreenShotWrapper(
disableScreenShot: true,
backgroundPreviewWidget: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors:[Colors.grey[300]!, Colors.grey],
),
),
width: double.infinity,
height: double.infinity,
child: Center(
child: Icon(Icons.lock, size: 50, color: Colors.white),
),
),
child: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Example(),
),
);
Properties | Description |
---|---|
backgroundPreviewWidget | Add Your own custom preview widget |
disableScreenShot | set to true to disable screenshot |
showBackgroundPreview | set to false to disable background preview |
Feel free to post a feature requests or report a bug here.
My Other packages
- zo_animated_border: A package that provides a modern way to create gradient borders with animation in Flutter
- connectivity_watcher: A Flutter package to monitor internet connectivity with subsecond response times, even on mobile networks.
- ultimate_extension: Enhances Dart collections and objects with utilities for advanced data manipulation and simpler coding.
- theme_manager_plus: Allows customization of your app's theme with your own theme class, eliminating the need for traditional
- date_util_plus: A powerful Dart API designed to augment and simplify date and time handling in your Dart projects.
- pick_color: A Flutter package that allows you to extract colors and hex codes from images with a simple touch.