pkb_no_screenshots 1.0.1 copy "pkb_no_screenshots: ^1.0.1" to clipboard
pkb_no_screenshots: ^1.0.1 copied to clipboard

PlatformAndroid

A new Flutter package no screenshots.

PKB No Screenshots #

Flutter plugin to enable, disable or toggle screenshot support in your application.  ios and android.

Usage #

const Text(
              'ScreenshotIOS',
            ),
            ElevatedButton(
              onPressed: () {
                DisableScreenshots.disable_enable('');
              },
              child:  Text('Disabled'),
            ),

            const Text(
              'ScreenshotAndroid',
            ),
            ElevatedButton(
              child: const Text('Press to turn off screenshot'),
              onPressed: ()  {
                DisableScreenshots.disable_enable('D');
              },
            ),
            ElevatedButton(
              child: const Text('Press to turn on screenshot'),
              onPressed: ()  {
                DisableScreenshots.disable_enable('E');
              },
            ),

Add native ios #

Add code to your ios/Runner/AppDelegate.swift dependencies

Usage #

import UIKit
import Flutter

let CHANNEL = "disableScreenshots"
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    let controller: FlutterViewController = window?.rootViewController as! FlutterViewController
    let channel = FlutterMethodChannel(name: CHANNEL, binaryMessenger: controller.binaryMessenger)
    channel.setMethodCallHandler({
                [weak self] (call: FlutterMethodCall, result: FlutterResult) -> Void in
                   if (call.method == "disable") {
                        self?.window?.makeSecureDisable()
                    }
            })
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

extension UIWindow {
    func makeSecureDisable() {
        let field = UITextField()
        let view = UIView(frame: CGRect(x: 0, y: 0, width: field.frame.self.width, height: field.frame.self.height))
        field.isSecureTextEntry = true
        self.addSubview(field)
        self.layer.superlayer?.addSublayer(field.layer)
        field.layer.sublayers?.last!.addSublayer(self.layer)
        field.leftView = view
        field.leftViewMode = .always
    }
}

1
likes
130
pub points
25%
popularity

Publisher

unverified uploader

A new Flutter package no screenshots.

Repository (GitHub)
View/report issues

Documentation

API reference

License

GPL-3.0 (LICENSE)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on pkb_no_screenshots