├── .gitignore ├── .idea ├── codeStyles │ └── Project.xml ├── kotlinc.xml ├── libraries │ ├── Dart_SDK.xml │ ├── Flutter_Plugins.xml │ ├── Flutter_for_Android.xml │ └── KotlinJavaRuntime.xml ├── misc.xml ├── modules.xml ├── runConfigurations │ └── example_lib_main_dart.xml └── workspace.xml ├── .metadata ├── .vscode └── settings.json ├── CHANGELOG.md ├── LICENSE ├── README.md ├── android ├── .classpath ├── .gitignore ├── .idea │ ├── .name │ ├── caches │ │ └── build_file_checksums.ser │ ├── codeStyles │ │ └── Project.xml │ ├── gradle.xml │ ├── jarRepositories.xml │ ├── misc.xml │ ├── modules.xml │ ├── runConfigurations.xml │ └── vcs.xml ├── .project ├── .settings │ └── org.eclipse.buildship.core.prefs ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── settings.gradle └── src │ └── main │ ├── AndroidManifest.xml │ └── kotlin │ └── com │ └── devlxx │ └── disable_screenshots │ ├── DisableScreenshotsPlugin.kt │ ├── ScreenShotListenManager.java │ └── test.kt ├── demo.gif ├── disable_screenshots.iml ├── example ├── .gitignore ├── .metadata ├── README.md ├── android │ ├── .gitignore │ ├── .project │ ├── .settings │ │ └── org.eclipse.buildship.core.prefs │ ├── app │ │ ├── .classpath │ │ ├── .project │ │ ├── .settings │ │ │ └── org.eclipse.buildship.core.prefs │ │ ├── build.gradle │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── kotlin │ │ │ │ └── com │ │ │ │ │ └── devlxx │ │ │ │ │ └── disable_screenshots_example │ │ │ │ │ └── MainActivity.kt │ │ │ └── res │ │ │ │ ├── drawable │ │ │ │ └── launch_background.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ └── values │ │ │ │ └── styles.xml │ │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── settings.gradle ├── ios │ ├── .gitignore │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ └── Release.xcconfig │ ├── Podfile │ ├── Podfile.lock │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ │ └── WorkspaceSettings.xcsettings │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ └── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ ├── Icon-App-20x20@1x.png │ │ │ ├── Icon-App-20x20@2x.png │ │ │ ├── Icon-App-20x20@3x.png │ │ │ ├── Icon-App-29x29@1x.png │ │ │ ├── Icon-App-29x29@2x.png │ │ │ ├── Icon-App-29x29@3x.png │ │ │ ├── Icon-App-40x40@1x.png │ │ │ ├── Icon-App-40x40@2x.png │ │ │ ├── Icon-App-40x40@3x.png │ │ │ ├── Icon-App-60x60@2x.png │ │ │ ├── Icon-App-60x60@3x.png │ │ │ ├── Icon-App-76x76@1x.png │ │ │ ├── Icon-App-76x76@2x.png │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ └── LaunchImage.imageset │ │ │ ├── Contents.json │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ └── README.md │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── Runner-Bridging-Header.h ├── lib │ └── main.dart ├── pubspec.yaml └── test │ └── widget_test.dart ├── ios ├── .gitignore ├── Assets │ └── .gitkeep ├── Classes │ ├── DisableScreenshotsPlugin.h │ ├── DisableScreenshotsPlugin.m │ └── SwiftDisableScreenshotsPlugin.swift └── disable_screenshots.podspec ├── lib ├── disable_screenshots.dart └── src │ ├── disable_screenshots.dart │ └── disable_screenshots_watarmark.dart ├── pubspec.yaml └── test └── disable_screenshots_test.dart /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .dart_tool/ 3 | 4 | .packages 5 | .pub/ 6 | 7 | build/ 8 | 9 | pubspec.lock 10 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | xmlns:android 14 | 15 | ^$ 16 | 17 | 18 | 19 |
20 |
21 | 22 | 23 | 24 | xmlns:.* 25 | 26 | ^$ 27 | 28 | 29 | BY_NAME 30 | 31 |
32 |
33 | 34 | 35 | 36 | .*:id 37 | 38 | http://schemas.android.com/apk/res/android 39 | 40 | 41 | 42 |
43 |
44 | 45 | 46 | 47 | .*:name 48 | 49 | http://schemas.android.com/apk/res/android 50 | 51 | 52 | 53 |
54 |
55 | 56 | 57 | 58 | name 59 | 60 | ^$ 61 | 62 | 63 | 64 |
65 |
66 | 67 | 68 | 69 | style 70 | 71 | ^$ 72 | 73 | 74 | 75 |
76 |
77 | 78 | 79 | 80 | .* 81 | 82 | ^$ 83 | 84 | 85 | BY_NAME 86 | 87 |
88 |
89 | 90 | 91 | 92 | .* 93 | 94 | http://schemas.android.com/apk/res/android 95 | 96 | 97 | ANDROID_ATTRIBUTE_ORDER 98 | 99 |
100 |
101 | 102 | 103 | 104 | .* 105 | 106 | .* 107 | 108 | 109 | BY_NAME 110 | 111 |
112 |
113 |
114 |
115 |
116 |
-------------------------------------------------------------------------------- /.idea/kotlinc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/libraries/Dart_SDK.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/libraries/Flutter_Plugins.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/libraries/Flutter_for_Android.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/libraries/KotlinJavaRuntime.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/runConfigurations/example_lib_main_dart.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | 17 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 1591774882430 35 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: f7a6a7906be96d2288f5d63a5a54c515a6e987fe 8 | channel: stable 9 | 10 | project_type: plugin 11 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.configuration.updateBuildConfiguration": "automatic" 3 | } -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.0.1 2 | 3 | * 第一次提交 4 | 5 | ## 0.1.0 6 | 7 | * 代码格式优化 8 | * 添加license 9 | 10 | ## 0.2.0 11 | 12 | * support null safety -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Stellar Lee 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # disable_screenshots 2 | 3 | 在Flutter开发中,有时我们需要对App的内容进行管控,避免敏感信息暴露,所以开发了这个插件。此插件提供三个禁用截屏的相关功能,分别是:`截屏监控行为`、`全局添加水印`、`禁用截屏(仅支持Android)`。 4 | 5 | ## Getting Started 6 | 7 | ### Add dependency 8 | ``` 9 | dependencies: 10 | disable_screenshots: 0.0.1 #latest version 11 | ``` 12 | 13 | ### 功能演示 14 | ![demo_gif](demo.gif) 15 | 16 | ### 使用样例 17 | ```dart 18 | class RootApp extends StatefulWidget { 19 | @override 20 | _RootAppState createState() => _RootAppState(); 21 | } 22 | 23 | class _RootAppState extends State { 24 | // 初始化插件 25 | DisableScreenshots _plugin = DisableScreenshots(); 26 | // 监控截屏行为的stream 27 | StreamSubscription _screenshotsSubscription; 28 | int _screenshotsCount = 0; 29 | bool _disableScreenshots = false; 30 | 31 | @override 32 | void initState() { 33 | super.initState(); 34 | _screenshotsSubscription = _plugin.onScreenShots.listen((event) { 35 | // 监控到截屏行为会回调到这里 36 | setState(() { 37 | _screenshotsCount++; 38 | }); 39 | }); 40 | } 41 | 42 | @override 43 | Widget build(BuildContext context) { 44 | return Scaffold( 45 | appBar: AppBar( 46 | title: const Text('禁止截屏'), 47 | ), 48 | body: Column( 49 | children: [ 50 | Center( 51 | child: Text("监控到截屏次数:$_screenshotsCount"), 52 | ), 53 | Center( 54 | child: Text(_disableScreenshots ? "禁止截屏状态" : "允许截屏状态"), 55 | ), 56 | RaisedButton( 57 | onPressed: () { 58 | // 添加默认样式的水印 59 | _plugin.addWatermark(context, "默认水印", 60 | rowCount: 4, columnCount: 8); 61 | }, 62 | child: Text("添加默认水印")), 63 | RaisedButton( 64 | onPressed: () { 65 | // 添加自定义widget当做水印 66 | _plugin.addCustomWatermark(context, 67 | Watarmark(rowCount: 3, columnCount: 10, text: "自定义水印")); 68 | }, 69 | child: Text("添加自定义水印")), 70 | RaisedButton( 71 | onPressed: () { 72 | // 移除水印 73 | _plugin.removeWatermark(); 74 | }, 75 | child: Text("删除水印")), 76 | RaisedButton( 77 | onPressed: () async { 78 | bool flag = !_disableScreenshots; 79 | // 禁用或允许截屏(只支持iOS) 80 | await _plugin.disableScreenshots(flag); 81 | setState(() { 82 | _disableScreenshots = flag; 83 | }); 84 | }, 85 | child: Text(_disableScreenshots ? "允许截屏(仅android适用)" : "禁用截屏(仅android适用)")), 86 | RaisedButton( 87 | onPressed: () { 88 | Navigator.of(context).push(MaterialPageRoute( 89 | builder: (_) => Scaffold( 90 | appBar: AppBar( 91 | title: Text("我是新页面"), 92 | ), 93 | body: Center(child: Text("new page")), 94 | ))); 95 | }, 96 | child: Text("进入新页面")) 97 | ], 98 | ), 99 | ); 100 | } 101 | 102 | @override 103 | void dispose() { 104 | super.dispose(); 105 | //取消截屏监控可以调用cancel()方法 106 | if (_screenshotsSubscription != null) { 107 | _screenshotsSubscription.cancel(); 108 | } 109 | } 110 | } 111 | ``` 112 | 113 | ### 已知问题 114 | 1. 在老的flutter项目中,在iOS平台运行可能出现编译问题无法运行。这个是由于老的flutter项目里面没有使用到swift,所以没有briging文件,但是插件使用了swift,所以会编译失败,这种情况直接使用xcode在iOS项目中创建一个swift文件,会自动生成briding文件。 115 | 2. 在某些安卓设备上(华为P30、Mi 10、三星Note10、OPPO reno3 Pro等),存在不能捕获截屏事件的问题,如果大家有解决方案,请提交`pull request`,谢谢! 116 | 117 | ### 其它 118 | 此Plugin的创建流程,可以参考博文[如何创建一个Flutter Plugin](https://blog.devlxx.com/2020/06/15/%E5%A6%82%E4%BD%95%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AAFlutter-Plugin/) -------------------------------------------------------------------------------- /android/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /android/.idea/.name: -------------------------------------------------------------------------------- 1 | disable_screenshots -------------------------------------------------------------------------------- /android/.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xx-li/disable_screenshots/b97d275bdacd76f573841efe5fac9a42f26aa77b/android/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /android/.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | xmlns:android 14 | 15 | ^$ 16 | 17 | 18 | 19 |
20 |
21 | 22 | 23 | 24 | xmlns:.* 25 | 26 | ^$ 27 | 28 | 29 | BY_NAME 30 | 31 |
32 |
33 | 34 | 35 | 36 | .*:id 37 | 38 | http://schemas.android.com/apk/res/android 39 | 40 | 41 | 42 |
43 |
44 | 45 | 46 | 47 | .*:name 48 | 49 | http://schemas.android.com/apk/res/android 50 | 51 | 52 | 53 |
54 |
55 | 56 | 57 | 58 | name 59 | 60 | ^$ 61 | 62 | 63 | 64 |
65 |
66 | 67 | 68 | 69 | style 70 | 71 | ^$ 72 | 73 | 74 | 75 |
76 |
77 | 78 | 79 | 80 | .* 81 | 82 | ^$ 83 | 84 | 85 | BY_NAME 86 | 87 |
88 |
89 | 90 | 91 | 92 | .* 93 | 94 | http://schemas.android.com/apk/res/android 95 | 96 | 97 | ANDROID_ATTRIBUTE_ORDER 98 | 99 |
100 |
101 | 102 | 103 | 104 | .* 105 | 106 | .* 107 | 108 | 109 | BY_NAME 110 | 111 |
112 |
113 |
114 |
115 |
116 |
-------------------------------------------------------------------------------- /android/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 19 | 20 | -------------------------------------------------------------------------------- /android/.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | -------------------------------------------------------------------------------- /android/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | -------------------------------------------------------------------------------- /android/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /android/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /android/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | disable_screenshots 4 | Project disable_screenshots created by Buildship. 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.buildship.core.gradleprojectbuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.buildship.core.gradleprojectnature 22 | 23 | 24 | -------------------------------------------------------------------------------- /android/.settings/org.eclipse.buildship.core.prefs: -------------------------------------------------------------------------------- 1 | arguments= 2 | auto.sync=false 3 | build.scans.enabled=false 4 | connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(6.3)) 5 | connection.project.dir=../example/android/app 6 | eclipse.preferences.version=1 7 | gradle.user.home= 8 | java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_212.jdk/Contents/Home 9 | jvm.arguments= 10 | offline.mode=false 11 | override.workspace.settings=true 12 | show.console.view=true 13 | show.executions.view=true 14 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | group 'com.devlxx.disable_screenshots' 2 | version '1.0-SNAPSHOT' 3 | 4 | buildscript { 5 | ext.kotlin_version = '1.3.50' 6 | repositories { 7 | google() 8 | jcenter() 9 | } 10 | 11 | dependencies { 12 | classpath 'com.android.tools.build:gradle:3.5.0' 13 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 14 | } 15 | } 16 | 17 | rootProject.allprojects { 18 | repositories { 19 | google() 20 | jcenter() 21 | } 22 | } 23 | 24 | apply plugin: 'com.android.library' 25 | apply plugin: 'kotlin-android' 26 | 27 | android { 28 | compileSdkVersion 28 29 | 30 | sourceSets { 31 | main.java.srcDirs += 'src/main/kotlin' 32 | } 33 | defaultConfig { 34 | minSdkVersion 16 35 | } 36 | lintOptions { 37 | disable 'InvalidPackage' 38 | } 39 | } 40 | 41 | dependencies { 42 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 43 | } 44 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.enableR8=true 3 | android.useAndroidX=true 4 | android.enableJetifier=true 5 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip 6 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'disable_screenshots' 2 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/devlxx/disable_screenshots/DisableScreenshotsPlugin.kt: -------------------------------------------------------------------------------- 1 | package com.devlxx.disable_screenshots 2 | 3 | import android.app.Activity 4 | import android.content.Context 5 | import android.util.Log 6 | import android.view.WindowManager 7 | import androidx.annotation.NonNull; 8 | 9 | import io.flutter.embedding.engine.plugins.FlutterPlugin 10 | import io.flutter.embedding.engine.plugins.activity.ActivityAware 11 | import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding 12 | import io.flutter.plugin.common.BinaryMessenger 13 | import io.flutter.plugin.common.EventChannel 14 | import io.flutter.plugin.common.MethodCall 15 | import io.flutter.plugin.common.MethodChannel 16 | import io.flutter.plugin.common.MethodChannel.MethodCallHandler 17 | import io.flutter.plugin.common.MethodChannel.Result 18 | import io.flutter.plugin.common.PluginRegistry.Registrar 19 | import kotlin.coroutines.coroutineContext 20 | 21 | /** DisableScreenshotsPlugin */ 22 | public class DisableScreenshotsPlugin: FlutterPlugin, MethodCallHandler, EventChannel.StreamHandler, ActivityAware { 23 | /// The MethodChannel that will the communication between Flutter and native Android 24 | /// 25 | /// This local reference serves to register the plugin with the Flutter Engine and unregister it 26 | /// when the Flutter Engine is detached from the Activity 27 | private lateinit var channel : MethodChannel 28 | private lateinit var applicationContext: Context; 29 | private lateinit var activity: Activity; 30 | private var eventSink: EventChannel.EventSink? = null 31 | private lateinit var screenShotListenManager: ScreenShotListenManager; 32 | var disableScreenshots: Boolean = false 33 | 34 | override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { 35 | 36 | onAttachedToEngine(flutterPluginBinding.applicationContext, flutterPluginBinding.binaryMessenger) 37 | } 38 | 39 | // This static function is optional and equivalent to onAttachedToEngine. It supports the old 40 | // pre-Flutter-1.12 Android projects. You are encouraged to continue supporting 41 | // plugin registration via this function while apps migrate to use the new Android APIs 42 | // post-flutter-1.12 via https://flutter.dev/go/android-project-migration. 43 | // 44 | // It is encouraged to share logic between onAttachedToEngine and registerWith to keep 45 | // them functionally equivalent. Only one of onAttachedToEngine or registerWith will be called 46 | // depending on the user's project. onAttachedToEngine or registerWith must both be defined 47 | // in the same class. 48 | companion object { 49 | @JvmStatic 50 | fun registerWith(registrar: Registrar) { 51 | val plugin = DisableScreenshotsPlugin() 52 | plugin.activity = registrar.activity() 53 | plugin.onAttachedToEngine(registrar.context(), registrar.messenger()) 54 | } 55 | } 56 | 57 | private fun onAttachedToEngine(applicationContext: Context, messenger: BinaryMessenger) { 58 | this.applicationContext = applicationContext 59 | this.channel = MethodChannel(messenger, "com.devlxx.DisableScreenshots/disableScreenshots") 60 | val eventChannel = EventChannel(messenger, "com.devlxx.DisableScreenshots/observer") 61 | this.channel.setMethodCallHandler(this) 62 | eventChannel.setStreamHandler(this) 63 | } 64 | 65 | private fun setDisableScreenshotsStatus(disable: Boolean) { 66 | if (disable) { // 禁用截屏 67 | activity.window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE); 68 | println("禁用截屏") 69 | } else { // 允许截屏 70 | activity.window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE) 71 | println("允许截屏") 72 | } 73 | } 74 | 75 | override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) { 76 | if (call.method == "disableScreenshots") { 77 | var disable = call.argument("disable") == true 78 | setDisableScreenshotsStatus(disable) 79 | result.success("") 80 | } else { 81 | result.notImplemented() 82 | } 83 | } 84 | 85 | override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) { 86 | channel.setMethodCallHandler(null) 87 | } 88 | 89 | override fun onListen(arguments: Any?, events: EventChannel.EventSink?) { 90 | println("开始监听") 91 | eventSink = events 92 | // ScreenShotListenManager为一个实现了监听截屏功能的Manager 93 | screenShotListenManager = ScreenShotListenManager.newInstance(applicationContext) 94 | screenShotListenManager.setListener { imagePath -> 95 | println("监听到截屏,截屏图片地址是:$imagePath") 96 | // 发送事件给Flutter端,告知监听到了截屏行为。 97 | eventSink?.success("监听到截屏行为") 98 | } 99 | screenShotListenManager.startListen() 100 | } 101 | 102 | override fun onCancel(arguments: Any?) { 103 | screenShotListenManager.stopListen() 104 | eventSink = null 105 | } 106 | 107 | 108 | override fun onDetachedFromActivity() { 109 | 110 | } 111 | 112 | override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) { 113 | activity = binding.activity 114 | setDisableScreenshotsStatus(this.disableScreenshots) 115 | } 116 | 117 | override fun onAttachedToActivity(binding: ActivityPluginBinding) { 118 | activity = binding.activity 119 | setDisableScreenshotsStatus(this.disableScreenshots) 120 | } 121 | 122 | override fun onDetachedFromActivityForConfigChanges() { 123 | 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/devlxx/disable_screenshots/ScreenShotListenManager.java: -------------------------------------------------------------------------------- 1 | package com.devlxx.disable_screenshots; 2 | 3 | import android.content.Context; 4 | import android.database.ContentObserver; 5 | import android.database.Cursor; 6 | import android.graphics.BitmapFactory; 7 | import android.graphics.Point; 8 | import android.net.Uri; 9 | import android.os.Build; 10 | import android.os.Handler; 11 | import android.os.Looper; 12 | import android.provider.MediaStore; 13 | import android.text.TextUtils; 14 | import android.util.Log; 15 | import android.view.Display; 16 | import android.view.WindowManager; 17 | import java.lang.reflect.Method; 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | 22 | /** 23 | * Created by on 2017/8/2. 24 | */ 25 | 26 | public class ScreenShotListenManager { 27 | private static final String TAG = "ScreenShotListenManager"; 28 | 29 | /** 30 | * 读取媒体数据库时需要读取的列 31 | */ 32 | private static final String[] MEDIA_PROJECTIONS = { 33 | MediaStore.Images.ImageColumns.DATA, 34 | MediaStore.Images.ImageColumns.DATE_TAKEN, 35 | }; 36 | /** 37 | * 读取媒体数据库时需要读取的列, 其中 WIDTH 和 HEIGHT 字段在 API 16 以后才有 38 | */ 39 | private static final String[] MEDIA_PROJECTIONS_API_16 = { 40 | MediaStore.Images.ImageColumns.DATA, 41 | MediaStore.Images.ImageColumns.DATE_TAKEN, 42 | MediaStore.Images.ImageColumns.WIDTH, 43 | MediaStore.Images.ImageColumns.HEIGHT, 44 | }; 45 | 46 | /** 47 | * 截屏依据中的路径判断关键字 48 | */ 49 | private static final String[] KEYWORDS = { 50 | "screenshot", "screen_shot", "screen-shot", "screen shot", 51 | "screencapture", "screen_capture", "screen-capture", "screen capture", 52 | "screencap", "screen_cap", "screen-cap", "screen cap" 53 | }; 54 | 55 | private static Point sScreenRealSize; 56 | 57 | /** 58 | * 已回调过的路径 59 | */ 60 | private final static List sHasCallbackPaths = new ArrayList(); 61 | 62 | private Context mContext; 63 | 64 | private OnScreenShotListener mListener; 65 | 66 | private long mStartListenTime; 67 | 68 | /** 69 | * 内部存储器内容观察者 70 | */ 71 | private MediaContentObserver mInternalObserver; 72 | 73 | /** 74 | * 外部存储器内容观察者 75 | */ 76 | private MediaContentObserver mExternalObserver; 77 | 78 | /** 79 | * 运行在 UI 线程的 Handler, 用于运行监听器回调 80 | */ 81 | private final Handler mUiHandler = new Handler(Looper.getMainLooper()); 82 | 83 | private ScreenShotListenManager(Context context) { 84 | if (context == null) { 85 | throw new IllegalArgumentException("The context must not be null."); 86 | } 87 | mContext = context; 88 | 89 | // 获取屏幕真实的分辨率 90 | if (sScreenRealSize == null) { 91 | sScreenRealSize = getRealScreenSize(); 92 | if (sScreenRealSize != null) { 93 | Log.d(TAG, "Screen Real Size: " + sScreenRealSize.x + " * " + sScreenRealSize.y); 94 | } else { 95 | Log.w(TAG, "Get screen real size failed."); 96 | } 97 | } 98 | } 99 | 100 | public static ScreenShotListenManager newInstance(Context context) { 101 | assertInMainThread(); 102 | return new ScreenShotListenManager(context); 103 | } 104 | 105 | /** 106 | * 启动监听 107 | */ 108 | public void startListen() { 109 | assertInMainThread(); 110 | 111 | // sHasCallbackPaths.clear(); 112 | 113 | // 记录开始监听的时间戳 114 | mStartListenTime = System.currentTimeMillis(); 115 | 116 | // 创建内容观察者 117 | mInternalObserver = new MediaContentObserver(MediaStore.Images.Media.INTERNAL_CONTENT_URI, mUiHandler); 118 | mExternalObserver = new MediaContentObserver(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, mUiHandler); 119 | 120 | // 注册内容观察者 121 | mContext.getContentResolver().registerContentObserver( 122 | MediaStore.Images.Media.INTERNAL_CONTENT_URI, 123 | false, 124 | mInternalObserver 125 | ); 126 | mContext.getContentResolver().registerContentObserver( 127 | MediaStore.Images.Media.EXTERNAL_CONTENT_URI, 128 | false, 129 | mExternalObserver 130 | ); 131 | } 132 | 133 | /** 134 | * 停止监听 135 | */ 136 | public void stopListen() { 137 | assertInMainThread(); 138 | 139 | // 注销内容观察者 140 | if (mInternalObserver != null) { 141 | try { 142 | mContext.getContentResolver().unregisterContentObserver(mInternalObserver); 143 | } catch (Exception e) { 144 | e.printStackTrace(); 145 | } 146 | mInternalObserver = null; 147 | } 148 | if (mExternalObserver != null) { 149 | try { 150 | mContext.getContentResolver().unregisterContentObserver(mExternalObserver); 151 | } catch (Exception e) { 152 | e.printStackTrace(); 153 | } 154 | mExternalObserver = null; 155 | } 156 | 157 | // 清空数据 158 | mStartListenTime = 0; 159 | // sHasCallbackPaths.clear(); 160 | 161 | //切记!!!:必须设置为空 可能mListener 会隐式持有Activity导致释放不掉 162 | mListener = null; 163 | } 164 | 165 | /** 166 | * 处理媒体数据库的内容改变 167 | */ 168 | private void handleMediaContentChange(Uri contentUri) { 169 | Cursor cursor = null; 170 | try { 171 | // 数据改变时查询数据库中最后加入的一条数据 172 | cursor = mContext.getContentResolver().query( 173 | contentUri, 174 | Build.VERSION.SDK_INT < 16 ? MEDIA_PROJECTIONS : MEDIA_PROJECTIONS_API_16, 175 | null, 176 | null, 177 | MediaStore.Images.ImageColumns.DATE_ADDED + " desc limit 1" 178 | ); 179 | 180 | if (cursor == null) { 181 | Log.e(TAG, "Deviant logic."); 182 | return; 183 | } 184 | if (!cursor.moveToFirst()) { 185 | Log.d(TAG, "Cursor no data."); 186 | return; 187 | } 188 | 189 | // 获取各列的索引 190 | int dataIndex = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA); 191 | int dateTakenIndex = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATE_TAKEN); 192 | int widthIndex = -1; 193 | int heightIndex = -1; 194 | if (Build.VERSION.SDK_INT >= 16) { 195 | widthIndex = cursor.getColumnIndex(MediaStore.Images.ImageColumns.WIDTH); 196 | heightIndex = cursor.getColumnIndex(MediaStore.Images.ImageColumns.HEIGHT); 197 | } 198 | 199 | // 获取行数据 200 | String data = cursor.getString(dataIndex); 201 | long dateTaken = cursor.getLong(dateTakenIndex); 202 | int width = 0; 203 | int height = 0; 204 | if (widthIndex >= 0 && heightIndex >= 0) { 205 | width = cursor.getInt(widthIndex); 206 | height = cursor.getInt(heightIndex); 207 | } else { 208 | // API 16 之前, 宽高要手动获取 209 | Point size = getImageSize(data); 210 | width = size.x; 211 | height = size.y; 212 | } 213 | 214 | // 处理获取到的第一行数据 215 | handleMediaRowData(data, dateTaken, width, height); 216 | 217 | } catch (Exception e) { 218 | e.printStackTrace(); 219 | 220 | } finally { 221 | if (cursor != null && !cursor.isClosed()) { 222 | cursor.close(); 223 | } 224 | } 225 | } 226 | 227 | private Point getImageSize(String imagePath) { 228 | BitmapFactory.Options options = new BitmapFactory.Options(); 229 | options.inJustDecodeBounds = true; 230 | BitmapFactory.decodeFile(imagePath, options); 231 | return new Point(options.outWidth, options.outHeight); 232 | } 233 | 234 | /** 235 | * 处理获取到的一行数据 236 | */ 237 | private void handleMediaRowData(String data, long dateTaken, int width, int height) { 238 | if (checkScreenShot(data, dateTaken, width, height)) { 239 | Log.d(TAG, "ScreenShot: path = " + data + "; size = " + width + " * " + height 240 | + "; date = " + dateTaken); 241 | if (mListener != null && !checkCallback(data)) { 242 | mListener.onShot(data); 243 | } 244 | } else { 245 | // 如果在观察区间媒体数据库有数据改变,又不符合截屏规则,则输出到 log 待分析 246 | Log.w(TAG, "Media content changed, but not screenshot: path = " + data 247 | + "; size = " + width + " * " + height + "; date = " + dateTaken); 248 | } 249 | } 250 | 251 | /** 252 | * 判断指定的数据行是否符合截屏条件 253 | */ 254 | private boolean checkScreenShot(String data, long dateTaken, int width, int height) { 255 | /* 256 | * 判断依据一: 时间判断 257 | */ 258 | // 如果加入数据库的时间在开始监听之前, 或者与当前时间相差大于10秒, 则认为当前没有截屏 259 | if (dateTaken < mStartListenTime || (System.currentTimeMillis() - dateTaken) > 10 * 1000) { 260 | return false; 261 | } 262 | 263 | /* 264 | * 判断依据二: 尺寸判断 265 | */ 266 | if (sScreenRealSize != null) { 267 | // 如果图片尺寸超出屏幕, 则认为当前没有截屏 268 | if (!((width <= sScreenRealSize.x && height <= sScreenRealSize.y) 269 | || (height <= sScreenRealSize.x && width <= sScreenRealSize.y))) { 270 | return false; 271 | } 272 | } 273 | 274 | /* 275 | * 判断依据三: 路径判断 276 | */ 277 | if (TextUtils.isEmpty(data)) { 278 | return false; 279 | } 280 | data = data.toLowerCase(); 281 | // 判断图片路径是否含有指定的关键字之一, 如果有, 则认为当前截屏了 282 | for (String keyWork : KEYWORDS) { 283 | if (data.contains(keyWork)) { 284 | return true; 285 | } 286 | } 287 | 288 | return false; 289 | } 290 | 291 | /** 292 | * 判断是否已回调过, 某些手机ROM截屏一次会发出多次内容改变的通知;
293 | * 删除一个图片也会发通知, 同时防止删除图片时误将上一张符合截屏规则的图片当做是当前截屏. 294 | */ 295 | private boolean checkCallback(String imagePath) { 296 | if (sHasCallbackPaths.contains(imagePath)) { 297 | Log.d(TAG, "ScreenShot: imgPath has done" 298 | + "; imagePath = " + imagePath); 299 | return true; 300 | } 301 | // 大概缓存15~20条记录便可 302 | if (sHasCallbackPaths.size() >= 20) { 303 | for (int i = 0; i < 5; i++) { 304 | sHasCallbackPaths.remove(0); 305 | } 306 | } 307 | sHasCallbackPaths.add(imagePath); 308 | return false; 309 | } 310 | 311 | /** 312 | * 获取屏幕分辨率 313 | */ 314 | private Point getRealScreenSize() { 315 | Point screenSize = null; 316 | try { 317 | screenSize = new Point(); 318 | WindowManager windowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); 319 | Display defaultDisplay = windowManager.getDefaultDisplay(); 320 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { 321 | defaultDisplay.getRealSize(screenSize); 322 | } else { 323 | try { 324 | Method mGetRawW = Display.class.getMethod("getRawWidth"); 325 | Method mGetRawH = Display.class.getMethod("getRawHeight"); 326 | screenSize.set( 327 | (Integer) mGetRawW.invoke(defaultDisplay), 328 | (Integer) mGetRawH.invoke(defaultDisplay) 329 | ); 330 | } catch (Exception e) { 331 | screenSize.set(defaultDisplay.getWidth(), defaultDisplay.getHeight()); 332 | e.printStackTrace(); 333 | } 334 | } 335 | } catch (Exception e) { 336 | e.printStackTrace(); 337 | } 338 | return screenSize; 339 | } 340 | 341 | // public Bitmap createScreenShotBitmap(Context context, String screenFilePath) { 342 | // 343 | // View v = LayoutInflater.from(context).inflate(R.layout.share_screenshot_layout, null); 344 | // ImageView iv = (ImageView) v.findViewById(R.id.iv); 345 | // Bitmap bitmap = BitmapFactory.decodeFile(screenFilePath); 346 | // iv.setImageBitmap(bitmap); 347 | // 348 | // //整体布局 349 | // Point point = getRealScreenSize(); 350 | // v.measure(View.MeasureSpec.makeMeasureSpec(point.x, View.MeasureSpec.EXACTLY), 351 | // View.MeasureSpec.makeMeasureSpec(point.y, View.MeasureSpec.EXACTLY)); 352 | // 353 | // v.layout(0, 0, point.x, point.y); 354 | // 355 | //// Bitmap result = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.RGB_565); 356 | // Bitmap result = Bitmap.createBitmap(v.getWidth(), v.getHeight() + dp2px(context, 140), Bitmap.Config.ARGB_8888); 357 | // Canvas c = new Canvas(result); 358 | // c.drawColor(Color.WHITE); 359 | // // Draw view to canvas 360 | // v.draw(c); 361 | // 362 | // return result; 363 | // } 364 | // 365 | // private int dp2px(Context ctx, float dp) { 366 | // float scale = ctx.getResources().getDisplayMetrics().density; 367 | // return (int) (dp * scale + 0.5f); 368 | // } 369 | 370 | /** 371 | * 设置截屏监听器 372 | */ 373 | public void setListener(OnScreenShotListener listener) { 374 | mListener = listener; 375 | } 376 | 377 | public interface OnScreenShotListener { 378 | void onShot(String imagePath); 379 | } 380 | 381 | private static void assertInMainThread() { 382 | if (Looper.myLooper() != Looper.getMainLooper()) { 383 | StackTraceElement[] elements = Thread.currentThread().getStackTrace(); 384 | String methodMsg = null; 385 | if (elements != null && elements.length >= 4) { 386 | methodMsg = elements[3].toString(); 387 | } 388 | throw new IllegalStateException("Call the method must be in main thread: " + methodMsg); 389 | } 390 | } 391 | 392 | /** 393 | * 媒体内容观察者(观察媒体数据库的改变) 394 | */ 395 | private class MediaContentObserver extends ContentObserver { 396 | 397 | private Uri mContentUri; 398 | 399 | public MediaContentObserver(Uri contentUri, Handler handler) { 400 | super(handler); 401 | mContentUri = contentUri; 402 | } 403 | 404 | @Override 405 | public void onChange(boolean selfChange) { 406 | super.onChange(selfChange); 407 | handleMediaContentChange(mContentUri); 408 | } 409 | } 410 | } 411 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/devlxx/disable_screenshots/test.kt: -------------------------------------------------------------------------------- 1 | package com.devlxx.disable_screenshots 2 | 3 | import android.util.Log 4 | 5 | class test { 6 | private fun bsgfdfsdsf() { 7 | val screenShotListenManager = ScreenShotListenManager.newInstance(null) 8 | screenShotListenManager.setListener { imagePath -> 9 | val index = imagePath[5].toInt() 10 | Log.w("TAG", "Get screen real size failed.") 11 | } 12 | screenShotListenManager.startListen() 13 | } 14 | } -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xx-li/disable_screenshots/b97d275bdacd76f573841efe5fac9a42f26aa77b/demo.gif -------------------------------------------------------------------------------- /disable_screenshots.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | .dart_tool/ 26 | .flutter-plugins 27 | .flutter-plugins-dependencies 28 | .packages 29 | .pub-cache/ 30 | .pub/ 31 | /build/ 32 | 33 | # Web related 34 | lib/generated_plugin_registrant.dart 35 | 36 | # Symbolication related 37 | app.*.symbols 38 | 39 | # Obfuscation related 40 | app.*.map.json 41 | 42 | # Exceptions to above rules. 43 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 44 | -------------------------------------------------------------------------------- /example/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: f7a6a7906be96d2288f5d63a5a54c515a6e987fe 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # disable_screenshots_example 2 | 3 | ```dart 4 | class RootApp extends StatefulWidget { 5 | @override 6 | _RootAppState createState() => _RootAppState(); 7 | } 8 | 9 | class _RootAppState extends State { 10 | // 初始化插件 11 | DisableScreenshots _plugin = DisableScreenshots(); 12 | // 监控截屏行为的stream 13 | StreamSubscription _screenshotsSubscription; 14 | int _screenshotsCount = 0; 15 | bool _disableScreenshots = false; 16 | 17 | @override 18 | void initState() { 19 | super.initState(); 20 | _screenshotsSubscription = _plugin.onScreenShots.listen((event) { 21 | setState(() { 22 | _screenshotsCount++; 23 | }); 24 | }); 25 | } 26 | 27 | @override 28 | Widget build(BuildContext context) { 29 | return Scaffold( 30 | appBar: AppBar( 31 | title: const Text('禁止截屏'), 32 | ), 33 | body: Column( 34 | children: [ 35 | Center( 36 | child: Text("监控到截屏次数:$_screenshotsCount"), 37 | ), 38 | Center( 39 | child: Text(_disableScreenshots ? "禁止截屏状态" : "允许截屏状态"), 40 | ), 41 | RaisedButton( 42 | onPressed: () { 43 | // 添加默认样式的水印 44 | _plugin.addWatermark(context, "默认水印", 45 | rowCount: 4, columnCount: 8); 46 | }, 47 | child: Text("添加默认水印")), 48 | RaisedButton( 49 | onPressed: () { 50 | // 添加自定义widget当做水印 51 | _plugin.addCustomWatermark(context, 52 | Watarmark(rowCount: 3, columnCount: 10, text: "自定义水印")); 53 | }, 54 | child: Text("添加自定义水印")), 55 | RaisedButton( 56 | onPressed: () { 57 | // 移除水印 58 | _plugin.removeWatermark(); 59 | }, 60 | child: Text("删除水印")), 61 | RaisedButton( 62 | onPressed: () async { 63 | bool flag = !_disableScreenshots; 64 | // 禁用或允许截屏(只支持iOS) 65 | await _plugin.disableScreenshots(flag); 66 | setState(() { 67 | _disableScreenshots = flag; 68 | }); 69 | }, 70 | child: Text(_disableScreenshots ? "允许截屏(仅android适用)" : "禁用截屏(仅android适用)")), 71 | RaisedButton( 72 | onPressed: () { 73 | Navigator.of(context).push(MaterialPageRoute( 74 | builder: (_) => Scaffold( 75 | appBar: AppBar( 76 | title: Text("我是新页面"), 77 | ), 78 | body: Center(child: Text("new page")), 79 | ))); 80 | }, 81 | child: Text("进入新页面")) 82 | ], 83 | ), 84 | ); 85 | } 86 | 87 | @override 88 | void dispose() { 89 | super.dispose(); 90 | //取消截屏监控可以调用cancel()方法 91 | if (_screenshotsSubscription != null) { 92 | _screenshotsSubscription.cancel(); 93 | } 94 | } 95 | } 96 | 97 | class Watarmark extends StatelessWidget { 98 | final int rowCount; 99 | final int columnCount; 100 | final String text; 101 | 102 | const Watarmark( 103 | {Key key, 104 | @required this.rowCount, 105 | @required this.columnCount, 106 | @required this.text}) 107 | : super(key: key); 108 | 109 | @override 110 | Widget build(BuildContext context) { 111 | return IgnorePointer( 112 | child: Container( 113 | child: Column( 114 | children: creatColumnWidgets(), 115 | )), 116 | ); 117 | } 118 | 119 | List creatRowWdiges() { 120 | List list = []; 121 | for (var i = 0; i < rowCount; i++) { 122 | final widget = Expanded( 123 | child: Center( 124 | child: Transform.rotate( 125 | angle: pi / 10, 126 | child: Text( 127 | text, 128 | style: TextStyle( 129 | color: Color(0x08000000), 130 | fontSize: 18, 131 | decoration: TextDecoration.none), 132 | ), 133 | ))); 134 | list.add(widget); 135 | } 136 | return list; 137 | } 138 | 139 | List creatColumnWidgets() { 140 | List list = []; 141 | for (var i = 0; i < columnCount; i++) { 142 | final widget = Expanded( 143 | child: Row( 144 | children: creatRowWdiges(), 145 | )); 146 | list.add(widget); 147 | } 148 | return list; 149 | } 150 | } 151 | ``` 152 | -------------------------------------------------------------------------------- /example/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | -------------------------------------------------------------------------------- /example/android/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | android 4 | Project android created by Buildship. 5 | 6 | 7 | 8 | 9 | org.eclipse.buildship.core.gradleprojectbuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.buildship.core.gradleprojectnature 16 | 17 | 18 | -------------------------------------------------------------------------------- /example/android/.settings/org.eclipse.buildship.core.prefs: -------------------------------------------------------------------------------- 1 | arguments= 2 | auto.sync=false 3 | build.scans.enabled=false 4 | connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) 5 | connection.project.dir=app 6 | eclipse.preferences.version=1 7 | gradle.user.home= 8 | java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_212.jdk/Contents/Home 9 | jvm.arguments= 10 | offline.mode=false 11 | override.workspace.settings=true 12 | show.console.view=true 13 | show.executions.view=true 14 | -------------------------------------------------------------------------------- /example/android/app/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /example/android/app/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | app 4 | Project app created by Buildship. 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.buildship.core.gradleprojectbuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.buildship.core.gradleprojectnature 22 | 23 | 24 | -------------------------------------------------------------------------------- /example/android/app/.settings/org.eclipse.buildship.core.prefs: -------------------------------------------------------------------------------- 1 | connection.project.dir= 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion 28 30 | 31 | sourceSets { 32 | main.java.srcDirs += 'src/main/kotlin' 33 | } 34 | 35 | lintOptions { 36 | disable 'InvalidPackage' 37 | } 38 | 39 | defaultConfig { 40 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 41 | applicationId "com.devlxx.disable_screenshots_example" 42 | minSdkVersion 16 43 | targetSdkVersion 28 44 | versionCode flutterVersionCode.toInteger() 45 | versionName flutterVersionName 46 | } 47 | 48 | buildTypes { 49 | release { 50 | // TODO: Add your own signing config for the release build. 51 | // Signing with the debug keys for now, so `flutter run --release` works. 52 | signingConfig signingConfigs.debug 53 | } 54 | } 55 | } 56 | 57 | flutter { 58 | source '../..' 59 | } 60 | 61 | dependencies { 62 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 63 | } 64 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 8 | 12 | 19 | 23 | 27 | 32 | 36 | 37 | 38 | 39 | 40 | 41 | 43 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /example/android/app/src/main/kotlin/com/devlxx/disable_screenshots_example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.devlxx.disable_screenshots_example 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xx-li/disable_screenshots/b97d275bdacd76f573841efe5fac9a42f26aa77b/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xx-li/disable_screenshots/b97d275bdacd76f573841efe5fac9a42f26aa77b/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xx-li/disable_screenshots/b97d275bdacd76f573841efe5fac9a42f26aa77b/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xx-li/disable_screenshots/b97d275bdacd76f573841efe5fac9a42f26aa77b/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xx-li/disable_screenshots/b97d275bdacd76f573841efe5fac9a42f26aa77b/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.3.50' 3 | repositories { 4 | google() 5 | jcenter() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:4.0.0' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | jcenter() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | task clean(type: Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.enableR8=true 3 | android.useAndroidX=true 4 | android.enableJetifier=true 5 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Jun 10 16:28:54 CST 2020 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip 7 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() 4 | 5 | def plugins = new Properties() 6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') 7 | if (pluginsFile.exists()) { 8 | pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } 9 | } 10 | 11 | plugins.each { name, path -> 12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() 13 | include ":$name" 14 | project(":$name").projectDir = pluginDirectory 15 | } 16 | -------------------------------------------------------------------------------- /example/ios/.gitignore: -------------------------------------------------------------------------------- 1 | *.mode1v3 2 | *.mode2v3 3 | *.moved-aside 4 | *.pbxuser 5 | *.perspectivev3 6 | **/*sync/ 7 | .sconsign.dblite 8 | .tags* 9 | **/.vagrant/ 10 | **/DerivedData/ 11 | Icon? 12 | **/Pods/ 13 | **/.symlinks/ 14 | profile 15 | xcuserdata 16 | **/.generated/ 17 | Flutter/App.framework 18 | Flutter/Flutter.framework 19 | Flutter/Flutter.podspec 20 | Flutter/Generated.xcconfig 21 | Flutter/app.flx 22 | Flutter/app.zip 23 | Flutter/flutter_assets/ 24 | Flutter/flutter_export_environment.sh 25 | ServiceDefinitions.json 26 | Runner/GeneratedPluginRegistrant.* 27 | 28 | # Exceptions to above rules. 29 | !default.mode1v3 30 | !default.mode2v3 31 | !default.pbxuser 32 | !default.perspectivev3 33 | -------------------------------------------------------------------------------- /example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | end 36 | 37 | post_install do |installer| 38 | installer.pods_project.targets.each do |target| 39 | flutter_additional_ios_build_settings(target) 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /example/ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - disable_screenshots (0.0.1): 3 | - Flutter 4 | - Flutter (1.0.0) 5 | 6 | DEPENDENCIES: 7 | - disable_screenshots (from `.symlinks/plugins/disable_screenshots/ios`) 8 | - Flutter (from `Flutter`) 9 | 10 | EXTERNAL SOURCES: 11 | disable_screenshots: 12 | :path: ".symlinks/plugins/disable_screenshots/ios" 13 | Flutter: 14 | :path: Flutter 15 | 16 | SPEC CHECKSUMS: 17 | disable_screenshots: 3f3a1881efa341fcdad395fb2b25e11a9a7bce0b 18 | Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c 19 | 20 | PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c 21 | 22 | COCOAPODS: 1.10.1 23 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 51; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 11 | 268C9E8DF6F9E869FDDCFF09 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4F5F7C4CE73DCE4C9D8A7A6E /* Pods_Runner.framework */; }; 12 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 13 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 14 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 15 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 16 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXCopyFilesBuildPhase section */ 20 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = { 21 | isa = PBXCopyFilesBuildPhase; 22 | buildActionMask = 2147483647; 23 | dstPath = ""; 24 | dstSubfolderSpec = 10; 25 | files = ( 26 | ); 27 | name = "Embed Frameworks"; 28 | runOnlyForDeploymentPostprocessing = 0; 29 | }; 30 | /* End PBXCopyFilesBuildPhase section */ 31 | 32 | /* Begin PBXFileReference section */ 33 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 34 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 35 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 36 | 4ADFBDF007D9AA31BEF65E4D /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 37 | 4F5F7C4CE73DCE4C9D8A7A6E /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 38 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 39 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 40 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 41 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 42 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 43 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 44 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 45 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 46 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 47 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 48 | C933F95B06064DE375588045 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; 49 | D87D2DA924364435006B9855 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 50 | /* End PBXFileReference section */ 51 | 52 | /* Begin PBXFrameworksBuildPhase section */ 53 | 97C146EB1CF9000F007C117D /* Frameworks */ = { 54 | isa = PBXFrameworksBuildPhase; 55 | buildActionMask = 2147483647; 56 | files = ( 57 | 268C9E8DF6F9E869FDDCFF09 /* Pods_Runner.framework in Frameworks */, 58 | ); 59 | runOnlyForDeploymentPostprocessing = 0; 60 | }; 61 | /* End PBXFrameworksBuildPhase section */ 62 | 63 | /* Begin PBXGroup section */ 64 | 028E20CA4A6206C6B0D7C8BD /* Frameworks */ = { 65 | isa = PBXGroup; 66 | children = ( 67 | 4F5F7C4CE73DCE4C9D8A7A6E /* Pods_Runner.framework */, 68 | ); 69 | name = Frameworks; 70 | sourceTree = ""; 71 | }; 72 | 9740EEB11CF90186004384FC /* Flutter */ = { 73 | isa = PBXGroup; 74 | children = ( 75 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 76 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 77 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 78 | 9740EEB31CF90195004384FC /* Generated.xcconfig */, 79 | ); 80 | name = Flutter; 81 | sourceTree = ""; 82 | }; 83 | 97C146E51CF9000F007C117D = { 84 | isa = PBXGroup; 85 | children = ( 86 | 9740EEB11CF90186004384FC /* Flutter */, 87 | 97C146F01CF9000F007C117D /* Runner */, 88 | 97C146EF1CF9000F007C117D /* Products */, 89 | AFF7F9C5A7D792D2AA2B1884 /* Pods */, 90 | 028E20CA4A6206C6B0D7C8BD /* Frameworks */, 91 | ); 92 | sourceTree = ""; 93 | }; 94 | 97C146EF1CF9000F007C117D /* Products */ = { 95 | isa = PBXGroup; 96 | children = ( 97 | 97C146EE1CF9000F007C117D /* Runner.app */, 98 | ); 99 | name = Products; 100 | sourceTree = ""; 101 | }; 102 | 97C146F01CF9000F007C117D /* Runner */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | 97C146FA1CF9000F007C117D /* Main.storyboard */, 106 | 97C146FD1CF9000F007C117D /* Assets.xcassets */, 107 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 108 | 97C147021CF9000F007C117D /* Info.plist */, 109 | 97C146F11CF9000F007C117D /* Supporting Files */, 110 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 111 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 112 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, 113 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, 114 | ); 115 | path = Runner; 116 | sourceTree = ""; 117 | }; 118 | 97C146F11CF9000F007C117D /* Supporting Files */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | ); 122 | name = "Supporting Files"; 123 | sourceTree = ""; 124 | }; 125 | AFF7F9C5A7D792D2AA2B1884 /* Pods */ = { 126 | isa = PBXGroup; 127 | children = ( 128 | D87D2DA924364435006B9855 /* Pods-Runner.debug.xcconfig */, 129 | 4ADFBDF007D9AA31BEF65E4D /* Pods-Runner.release.xcconfig */, 130 | C933F95B06064DE375588045 /* Pods-Runner.profile.xcconfig */, 131 | ); 132 | path = Pods; 133 | sourceTree = ""; 134 | }; 135 | /* End PBXGroup section */ 136 | 137 | /* Begin PBXNativeTarget section */ 138 | 97C146ED1CF9000F007C117D /* Runner */ = { 139 | isa = PBXNativeTarget; 140 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; 141 | buildPhases = ( 142 | F814408FA7A809D1B6F3C659 /* [CP] Check Pods Manifest.lock */, 143 | 9740EEB61CF901F6004384FC /* Run Script */, 144 | 97C146EA1CF9000F007C117D /* Sources */, 145 | 97C146EB1CF9000F007C117D /* Frameworks */, 146 | 97C146EC1CF9000F007C117D /* Resources */, 147 | 9705A1C41CF9048500538489 /* Embed Frameworks */, 148 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 149 | 7A7D2FBC27D7F2BDDF6A560D /* [CP] Embed Pods Frameworks */, 150 | ); 151 | buildRules = ( 152 | ); 153 | dependencies = ( 154 | ); 155 | name = Runner; 156 | productName = Runner; 157 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */; 158 | productType = "com.apple.product-type.application"; 159 | }; 160 | /* End PBXNativeTarget section */ 161 | 162 | /* Begin PBXProject section */ 163 | 97C146E61CF9000F007C117D /* Project object */ = { 164 | isa = PBXProject; 165 | attributes = { 166 | LastUpgradeCheck = 1020; 167 | ORGANIZATIONNAME = ""; 168 | TargetAttributes = { 169 | 97C146ED1CF9000F007C117D = { 170 | CreatedOnToolsVersion = 7.3.1; 171 | LastSwiftMigration = 1100; 172 | }; 173 | }; 174 | }; 175 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; 176 | compatibilityVersion = "Xcode 9.3"; 177 | developmentRegion = en; 178 | hasScannedForEncodings = 0; 179 | knownRegions = ( 180 | en, 181 | Base, 182 | ); 183 | mainGroup = 97C146E51CF9000F007C117D; 184 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */; 185 | projectDirPath = ""; 186 | projectRoot = ""; 187 | targets = ( 188 | 97C146ED1CF9000F007C117D /* Runner */, 189 | ); 190 | }; 191 | /* End PBXProject section */ 192 | 193 | /* Begin PBXResourcesBuildPhase section */ 194 | 97C146EC1CF9000F007C117D /* Resources */ = { 195 | isa = PBXResourcesBuildPhase; 196 | buildActionMask = 2147483647; 197 | files = ( 198 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 199 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 200 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 201 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 202 | ); 203 | runOnlyForDeploymentPostprocessing = 0; 204 | }; 205 | /* End PBXResourcesBuildPhase section */ 206 | 207 | /* Begin PBXShellScriptBuildPhase section */ 208 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 209 | isa = PBXShellScriptBuildPhase; 210 | buildActionMask = 2147483647; 211 | files = ( 212 | ); 213 | inputPaths = ( 214 | ); 215 | name = "Thin Binary"; 216 | outputPaths = ( 217 | ); 218 | runOnlyForDeploymentPostprocessing = 0; 219 | shellPath = /bin/sh; 220 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; 221 | }; 222 | 7A7D2FBC27D7F2BDDF6A560D /* [CP] Embed Pods Frameworks */ = { 223 | isa = PBXShellScriptBuildPhase; 224 | buildActionMask = 2147483647; 225 | files = ( 226 | ); 227 | inputFileListPaths = ( 228 | "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", 229 | ); 230 | name = "[CP] Embed Pods Frameworks"; 231 | outputFileListPaths = ( 232 | "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", 233 | ); 234 | runOnlyForDeploymentPostprocessing = 0; 235 | shellPath = /bin/sh; 236 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; 237 | showEnvVarsInLog = 0; 238 | }; 239 | 9740EEB61CF901F6004384FC /* Run Script */ = { 240 | isa = PBXShellScriptBuildPhase; 241 | buildActionMask = 2147483647; 242 | files = ( 243 | ); 244 | inputPaths = ( 245 | ); 246 | name = "Run Script"; 247 | outputPaths = ( 248 | ); 249 | runOnlyForDeploymentPostprocessing = 0; 250 | shellPath = /bin/sh; 251 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 252 | }; 253 | F814408FA7A809D1B6F3C659 /* [CP] Check Pods Manifest.lock */ = { 254 | isa = PBXShellScriptBuildPhase; 255 | buildActionMask = 2147483647; 256 | files = ( 257 | ); 258 | inputFileListPaths = ( 259 | ); 260 | inputPaths = ( 261 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 262 | "${PODS_ROOT}/Manifest.lock", 263 | ); 264 | name = "[CP] Check Pods Manifest.lock"; 265 | outputFileListPaths = ( 266 | ); 267 | outputPaths = ( 268 | "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", 269 | ); 270 | runOnlyForDeploymentPostprocessing = 0; 271 | shellPath = /bin/sh; 272 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 273 | showEnvVarsInLog = 0; 274 | }; 275 | /* End PBXShellScriptBuildPhase section */ 276 | 277 | /* Begin PBXSourcesBuildPhase section */ 278 | 97C146EA1CF9000F007C117D /* Sources */ = { 279 | isa = PBXSourcesBuildPhase; 280 | buildActionMask = 2147483647; 281 | files = ( 282 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, 283 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 284 | ); 285 | runOnlyForDeploymentPostprocessing = 0; 286 | }; 287 | /* End PBXSourcesBuildPhase section */ 288 | 289 | /* Begin PBXVariantGroup section */ 290 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = { 291 | isa = PBXVariantGroup; 292 | children = ( 293 | 97C146FB1CF9000F007C117D /* Base */, 294 | ); 295 | name = Main.storyboard; 296 | sourceTree = ""; 297 | }; 298 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { 299 | isa = PBXVariantGroup; 300 | children = ( 301 | 97C147001CF9000F007C117D /* Base */, 302 | ); 303 | name = LaunchScreen.storyboard; 304 | sourceTree = ""; 305 | }; 306 | /* End PBXVariantGroup section */ 307 | 308 | /* Begin XCBuildConfiguration section */ 309 | 249021D3217E4FDB00AE95B9 /* Profile */ = { 310 | isa = XCBuildConfiguration; 311 | buildSettings = { 312 | ALWAYS_SEARCH_USER_PATHS = NO; 313 | CLANG_ANALYZER_NONNULL = YES; 314 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 315 | CLANG_CXX_LIBRARY = "libc++"; 316 | CLANG_ENABLE_MODULES = YES; 317 | CLANG_ENABLE_OBJC_ARC = YES; 318 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 319 | CLANG_WARN_BOOL_CONVERSION = YES; 320 | CLANG_WARN_COMMA = YES; 321 | CLANG_WARN_CONSTANT_CONVERSION = YES; 322 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 323 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 324 | CLANG_WARN_EMPTY_BODY = YES; 325 | CLANG_WARN_ENUM_CONVERSION = YES; 326 | CLANG_WARN_INFINITE_RECURSION = YES; 327 | CLANG_WARN_INT_CONVERSION = YES; 328 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 329 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 330 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 331 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 332 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 333 | CLANG_WARN_STRICT_PROTOTYPES = YES; 334 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 335 | CLANG_WARN_UNREACHABLE_CODE = YES; 336 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 337 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 338 | COPY_PHASE_STRIP = NO; 339 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 340 | ENABLE_NS_ASSERTIONS = NO; 341 | ENABLE_STRICT_OBJC_MSGSEND = YES; 342 | GCC_C_LANGUAGE_STANDARD = gnu99; 343 | GCC_NO_COMMON_BLOCKS = YES; 344 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 345 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 346 | GCC_WARN_UNDECLARED_SELECTOR = YES; 347 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 348 | GCC_WARN_UNUSED_FUNCTION = YES; 349 | GCC_WARN_UNUSED_VARIABLE = YES; 350 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 351 | MTL_ENABLE_DEBUG_INFO = NO; 352 | SDKROOT = iphoneos; 353 | SUPPORTED_PLATFORMS = iphoneos; 354 | TARGETED_DEVICE_FAMILY = "1,2"; 355 | VALIDATE_PRODUCT = YES; 356 | }; 357 | name = Profile; 358 | }; 359 | 249021D4217E4FDB00AE95B9 /* Profile */ = { 360 | isa = XCBuildConfiguration; 361 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 362 | buildSettings = { 363 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 364 | CLANG_ENABLE_MODULES = YES; 365 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 366 | DEVELOPMENT_TEAM = PGLR8SXPQP; 367 | ENABLE_BITCODE = NO; 368 | FRAMEWORK_SEARCH_PATHS = ( 369 | "$(inherited)", 370 | "$(PROJECT_DIR)/Flutter", 371 | ); 372 | INFOPLIST_FILE = Runner/Info.plist; 373 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 374 | LD_RUNPATH_SEARCH_PATHS = ( 375 | "$(inherited)", 376 | "@executable_path/Frameworks", 377 | ); 378 | LIBRARY_SEARCH_PATHS = ( 379 | "$(inherited)", 380 | "$(PROJECT_DIR)/Flutter", 381 | ); 382 | PRODUCT_BUNDLE_IDENTIFIER = com.devlxx.disableScreenshotsExample; 383 | PRODUCT_NAME = "$(TARGET_NAME)"; 384 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 385 | SWIFT_VERSION = 5.0; 386 | VERSIONING_SYSTEM = "apple-generic"; 387 | }; 388 | name = Profile; 389 | }; 390 | 97C147031CF9000F007C117D /* Debug */ = { 391 | isa = XCBuildConfiguration; 392 | buildSettings = { 393 | ALWAYS_SEARCH_USER_PATHS = NO; 394 | CLANG_ANALYZER_NONNULL = YES; 395 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 396 | CLANG_CXX_LIBRARY = "libc++"; 397 | CLANG_ENABLE_MODULES = YES; 398 | CLANG_ENABLE_OBJC_ARC = YES; 399 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 400 | CLANG_WARN_BOOL_CONVERSION = YES; 401 | CLANG_WARN_COMMA = YES; 402 | CLANG_WARN_CONSTANT_CONVERSION = YES; 403 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 404 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 405 | CLANG_WARN_EMPTY_BODY = YES; 406 | CLANG_WARN_ENUM_CONVERSION = YES; 407 | CLANG_WARN_INFINITE_RECURSION = YES; 408 | CLANG_WARN_INT_CONVERSION = YES; 409 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 410 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 411 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 412 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 413 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 414 | CLANG_WARN_STRICT_PROTOTYPES = YES; 415 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 416 | CLANG_WARN_UNREACHABLE_CODE = YES; 417 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 418 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 419 | COPY_PHASE_STRIP = NO; 420 | DEBUG_INFORMATION_FORMAT = dwarf; 421 | ENABLE_STRICT_OBJC_MSGSEND = YES; 422 | ENABLE_TESTABILITY = YES; 423 | GCC_C_LANGUAGE_STANDARD = gnu99; 424 | GCC_DYNAMIC_NO_PIC = NO; 425 | GCC_NO_COMMON_BLOCKS = YES; 426 | GCC_OPTIMIZATION_LEVEL = 0; 427 | GCC_PREPROCESSOR_DEFINITIONS = ( 428 | "DEBUG=1", 429 | "$(inherited)", 430 | ); 431 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 432 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 433 | GCC_WARN_UNDECLARED_SELECTOR = YES; 434 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 435 | GCC_WARN_UNUSED_FUNCTION = YES; 436 | GCC_WARN_UNUSED_VARIABLE = YES; 437 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 438 | MTL_ENABLE_DEBUG_INFO = YES; 439 | ONLY_ACTIVE_ARCH = YES; 440 | SDKROOT = iphoneos; 441 | TARGETED_DEVICE_FAMILY = "1,2"; 442 | }; 443 | name = Debug; 444 | }; 445 | 97C147041CF9000F007C117D /* Release */ = { 446 | isa = XCBuildConfiguration; 447 | buildSettings = { 448 | ALWAYS_SEARCH_USER_PATHS = NO; 449 | CLANG_ANALYZER_NONNULL = YES; 450 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 451 | CLANG_CXX_LIBRARY = "libc++"; 452 | CLANG_ENABLE_MODULES = YES; 453 | CLANG_ENABLE_OBJC_ARC = YES; 454 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 455 | CLANG_WARN_BOOL_CONVERSION = YES; 456 | CLANG_WARN_COMMA = YES; 457 | CLANG_WARN_CONSTANT_CONVERSION = YES; 458 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 459 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 460 | CLANG_WARN_EMPTY_BODY = YES; 461 | CLANG_WARN_ENUM_CONVERSION = YES; 462 | CLANG_WARN_INFINITE_RECURSION = YES; 463 | CLANG_WARN_INT_CONVERSION = YES; 464 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 465 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 466 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 467 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 468 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 469 | CLANG_WARN_STRICT_PROTOTYPES = YES; 470 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 471 | CLANG_WARN_UNREACHABLE_CODE = YES; 472 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 473 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 474 | COPY_PHASE_STRIP = NO; 475 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 476 | ENABLE_NS_ASSERTIONS = NO; 477 | ENABLE_STRICT_OBJC_MSGSEND = YES; 478 | GCC_C_LANGUAGE_STANDARD = gnu99; 479 | GCC_NO_COMMON_BLOCKS = YES; 480 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 481 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 482 | GCC_WARN_UNDECLARED_SELECTOR = YES; 483 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 484 | GCC_WARN_UNUSED_FUNCTION = YES; 485 | GCC_WARN_UNUSED_VARIABLE = YES; 486 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 487 | MTL_ENABLE_DEBUG_INFO = NO; 488 | SDKROOT = iphoneos; 489 | SUPPORTED_PLATFORMS = iphoneos; 490 | SWIFT_COMPILATION_MODE = wholemodule; 491 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 492 | TARGETED_DEVICE_FAMILY = "1,2"; 493 | VALIDATE_PRODUCT = YES; 494 | }; 495 | name = Release; 496 | }; 497 | 97C147061CF9000F007C117D /* Debug */ = { 498 | isa = XCBuildConfiguration; 499 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 500 | buildSettings = { 501 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 502 | CLANG_ENABLE_MODULES = YES; 503 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 504 | DEVELOPMENT_TEAM = PGLR8SXPQP; 505 | ENABLE_BITCODE = NO; 506 | FRAMEWORK_SEARCH_PATHS = ( 507 | "$(inherited)", 508 | "$(PROJECT_DIR)/Flutter", 509 | ); 510 | INFOPLIST_FILE = Runner/Info.plist; 511 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 512 | LD_RUNPATH_SEARCH_PATHS = ( 513 | "$(inherited)", 514 | "@executable_path/Frameworks", 515 | ); 516 | LIBRARY_SEARCH_PATHS = ( 517 | "$(inherited)", 518 | "$(PROJECT_DIR)/Flutter", 519 | ); 520 | PRODUCT_BUNDLE_IDENTIFIER = com.devlxx.disableScreenshotsExample; 521 | PRODUCT_NAME = "$(TARGET_NAME)"; 522 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 523 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 524 | SWIFT_VERSION = 5.0; 525 | VERSIONING_SYSTEM = "apple-generic"; 526 | }; 527 | name = Debug; 528 | }; 529 | 97C147071CF9000F007C117D /* Release */ = { 530 | isa = XCBuildConfiguration; 531 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 532 | buildSettings = { 533 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 534 | CLANG_ENABLE_MODULES = YES; 535 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 536 | DEVELOPMENT_TEAM = PGLR8SXPQP; 537 | ENABLE_BITCODE = NO; 538 | FRAMEWORK_SEARCH_PATHS = ( 539 | "$(inherited)", 540 | "$(PROJECT_DIR)/Flutter", 541 | ); 542 | INFOPLIST_FILE = Runner/Info.plist; 543 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 544 | LD_RUNPATH_SEARCH_PATHS = ( 545 | "$(inherited)", 546 | "@executable_path/Frameworks", 547 | ); 548 | LIBRARY_SEARCH_PATHS = ( 549 | "$(inherited)", 550 | "$(PROJECT_DIR)/Flutter", 551 | ); 552 | PRODUCT_BUNDLE_IDENTIFIER = com.devlxx.disableScreenshotsExample; 553 | PRODUCT_NAME = "$(TARGET_NAME)"; 554 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 555 | SWIFT_VERSION = 5.0; 556 | VERSIONING_SYSTEM = "apple-generic"; 557 | }; 558 | name = Release; 559 | }; 560 | /* End XCBuildConfiguration section */ 561 | 562 | /* Begin XCConfigurationList section */ 563 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 564 | isa = XCConfigurationList; 565 | buildConfigurations = ( 566 | 97C147031CF9000F007C117D /* Debug */, 567 | 97C147041CF9000F007C117D /* Release */, 568 | 249021D3217E4FDB00AE95B9 /* Profile */, 569 | ); 570 | defaultConfigurationIsVisible = 0; 571 | defaultConfigurationName = Release; 572 | }; 573 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 574 | isa = XCConfigurationList; 575 | buildConfigurations = ( 576 | 97C147061CF9000F007C117D /* Debug */, 577 | 97C147071CF9000F007C117D /* Release */, 578 | 249021D4217E4FDB00AE95B9 /* Profile */, 579 | ); 580 | defaultConfigurationIsVisible = 0; 581 | defaultConfigurationName = Release; 582 | }; 583 | /* End XCConfigurationList section */ 584 | }; 585 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 586 | } 587 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xx-li/disable_screenshots/b97d275bdacd76f573841efe5fac9a42f26aa77b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xx-li/disable_screenshots/b97d275bdacd76f573841efe5fac9a42f26aa77b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xx-li/disable_screenshots/b97d275bdacd76f573841efe5fac9a42f26aa77b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xx-li/disable_screenshots/b97d275bdacd76f573841efe5fac9a42f26aa77b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xx-li/disable_screenshots/b97d275bdacd76f573841efe5fac9a42f26aa77b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xx-li/disable_screenshots/b97d275bdacd76f573841efe5fac9a42f26aa77b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xx-li/disable_screenshots/b97d275bdacd76f573841efe5fac9a42f26aa77b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xx-li/disable_screenshots/b97d275bdacd76f573841efe5fac9a42f26aa77b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xx-li/disable_screenshots/b97d275bdacd76f573841efe5fac9a42f26aa77b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xx-li/disable_screenshots/b97d275bdacd76f573841efe5fac9a42f26aa77b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xx-li/disable_screenshots/b97d275bdacd76f573841efe5fac9a42f26aa77b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xx-li/disable_screenshots/b97d275bdacd76f573841efe5fac9a42f26aa77b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xx-li/disable_screenshots/b97d275bdacd76f573841efe5fac9a42f26aa77b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xx-li/disable_screenshots/b97d275bdacd76f573841efe5fac9a42f26aa77b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xx-li/disable_screenshots/b97d275bdacd76f573841efe5fac9a42f26aa77b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xx-li/disable_screenshots/b97d275bdacd76f573841efe5fac9a42f26aa77b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xx-li/disable_screenshots/b97d275bdacd76f573841efe5fac9a42f26aa77b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xx-li/disable_screenshots/b97d275bdacd76f573841efe5fac9a42f26aa77b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | DisableScreenshotsExample 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | disable_screenshots_example 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UIViewControllerBasedStatusBarAppearance 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'dart:async'; 5 | 6 | import 'package:disable_screenshots/disable_screenshots.dart'; 7 | 8 | void main() { 9 | runApp(MyApp()); 10 | } 11 | 12 | class MyApp extends StatefulWidget { 13 | @override 14 | _MyAppState createState() => _MyAppState(); 15 | } 16 | 17 | class _MyAppState extends State { 18 | @override 19 | Widget build(BuildContext context) { 20 | return MaterialApp(home: RootApp()); 21 | } 22 | } 23 | 24 | class RootApp extends StatefulWidget { 25 | @override 26 | _RootAppState createState() => _RootAppState(); 27 | } 28 | 29 | class _RootAppState extends State { 30 | // 初始化插件 31 | DisableScreenshots _plugin = DisableScreenshots(); 32 | // 监控截屏行为的stream 33 | late StreamSubscription _screenshotsSubscription; 34 | int _screenshotsCount = 0; 35 | bool _disableScreenshots = false; 36 | 37 | @override 38 | void initState() { 39 | super.initState(); 40 | _screenshotsSubscription = _plugin.onScreenShots.listen((event) { 41 | setState(() { 42 | _screenshotsCount++; 43 | }); 44 | }); 45 | } 46 | 47 | @override 48 | Widget build(BuildContext context) { 49 | return Scaffold( 50 | appBar: AppBar( 51 | title: const Text('禁止截屏'), 52 | ), 53 | body: Column( 54 | children: [ 55 | SizedBox(height:100), 56 | Center( 57 | child: Text("监控到截屏次数:$_screenshotsCount"), 58 | ), 59 | Center( 60 | child: Text(_disableScreenshots ? "禁止截屏状态" : "允许截屏状态"), 61 | ), 62 | RaisedButton( 63 | onPressed: () { 64 | // 添加默认样式的水印 65 | _plugin.addWatermark(context, "默认水印", 66 | rowCount: 4, columnCount: 8); 67 | }, 68 | child: Text("添加默认水印")), 69 | RaisedButton( 70 | onPressed: () { 71 | // 添加自定义widget当做水印 72 | _plugin.addCustomWatermark(context, 73 | Watarmark(rowCount: 3, columnCount: 10, text: "自定义水印")); 74 | }, 75 | child: Text("添加自定义水印")), 76 | RaisedButton( 77 | onPressed: () { 78 | // 移除水印 79 | _plugin.removeWatermark(); 80 | }, 81 | child: Text("删除水印")), 82 | RaisedButton( 83 | onPressed: () async { 84 | bool flag = !_disableScreenshots; 85 | // 禁用或允许截屏(只支持iOS) 86 | await _plugin.disableScreenshots(flag); 87 | setState(() { 88 | _disableScreenshots = flag; 89 | }); 90 | }, 91 | child: Text(_disableScreenshots 92 | ? "允许截屏(仅android适用)" 93 | : "禁用截屏(仅android适用)")), 94 | RaisedButton( 95 | onPressed: () { 96 | Navigator.of(context).push(MaterialPageRoute( 97 | builder: (_) => Scaffold( 98 | appBar: AppBar( 99 | title: Text("我是新页面"), 100 | ), 101 | body: Center(child: Text("new page")), 102 | ))); 103 | }, 104 | child: Text("进入新页面")) 105 | ], 106 | ), 107 | ); 108 | } 109 | 110 | @override 111 | void dispose() { 112 | super.dispose(); 113 | //取消截屏监控可以调用cancel()方法 114 | if (_screenshotsSubscription != null) { 115 | _screenshotsSubscription.cancel(); 116 | } 117 | } 118 | } 119 | 120 | class Watarmark extends StatelessWidget { 121 | final int rowCount; 122 | final int columnCount; 123 | final String text; 124 | 125 | const Watarmark( 126 | {Key? key, 127 | required this.rowCount, 128 | required this.columnCount, 129 | required this.text}) 130 | : super(key: key); 131 | 132 | @override 133 | Widget build(BuildContext context) { 134 | return IgnorePointer( 135 | child: Container( 136 | child: Column( 137 | children: creatColumnWidgets(), 138 | )), 139 | ); 140 | } 141 | 142 | List creatRowWdiges() { 143 | List list = []; 144 | for (var i = 0; i < rowCount; i++) { 145 | final widget = Expanded( 146 | child: Center( 147 | child: Transform.rotate( 148 | angle: pi / 10, 149 | child: Text( 150 | text, 151 | style: TextStyle( 152 | color: Color(0x08000000), 153 | fontSize: 18, 154 | decoration: TextDecoration.none), 155 | ), 156 | ))); 157 | list.add(widget); 158 | } 159 | return list; 160 | } 161 | 162 | List creatColumnWidgets() { 163 | List list = []; 164 | for (var i = 0; i < columnCount; i++) { 165 | final widget = Expanded( 166 | child: Row( 167 | children: creatRowWdiges(), 168 | )); 169 | list.add(widget); 170 | } 171 | return list; 172 | } 173 | } 174 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: disable_screenshots_example 2 | description: Demonstrates how to use the disable_screenshots plugin. 3 | 4 | # The following line prevents the package from being accidentally published to 5 | # pub.dev using `pub publish`. This is preferred for private packages. 6 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev 7 | 8 | environment: 9 | sdk: ">=2.12.0 <3.0.0" 10 | 11 | dependencies: 12 | flutter: 13 | sdk: flutter 14 | 15 | disable_screenshots: 16 | # When depending on this package from a real application you should use: 17 | # disable_screenshots: ^x.y.z 18 | # See https://dart.dev/tools/pub/dependencies#version-constraints 19 | # The example app is bundled with the plugin so we use a path dependency on 20 | # the parent directory to use the current plugin's version. 21 | path: ../ 22 | 23 | # The following adds the Cupertino Icons font to your application. 24 | # Use with the CupertinoIcons class for iOS style icons. 25 | cupertino_icons: ^1.0.2 26 | 27 | dev_dependencies: 28 | flutter_test: 29 | sdk: flutter 30 | 31 | # For information on the generic Dart part of this file, see the 32 | # following page: https://dart.dev/tools/pub/pubspec 33 | 34 | # The following section is specific to Flutter. 35 | flutter: 36 | 37 | # The following line ensures that the Material Icons font is 38 | # included with your application, so that you can use the icons in 39 | # the material Icons class. 40 | uses-material-design: true 41 | 42 | # To add assets to your application, add an assets section, like this: 43 | # assets: 44 | # - images/a_dot_burr.jpeg 45 | # - images/a_dot_ham.jpeg 46 | 47 | # An image asset can refer to one or more resolution-specific "variants", see 48 | # https://flutter.dev/assets-and-images/#resolution-aware. 49 | 50 | # For details regarding adding assets from package dependencies, see 51 | # https://flutter.dev/assets-and-images/#from-packages 52 | 53 | # To add custom fonts to your application, add a fonts section here, 54 | # in this "flutter" section. Each entry in this list should have a 55 | # "family" key with the font family name, and a "fonts" key with a 56 | # list giving the asset and other descriptors for the font. For 57 | # example: 58 | # fonts: 59 | # - family: Schyler 60 | # fonts: 61 | # - asset: fonts/Schyler-Regular.ttf 62 | # - asset: fonts/Schyler-Italic.ttf 63 | # style: italic 64 | # - family: Trajan Pro 65 | # fonts: 66 | # - asset: fonts/TrajanPro.ttf 67 | # - asset: fonts/TrajanPro_Bold.ttf 68 | # weight: 700 69 | # 70 | # For details regarding fonts from package dependencies, 71 | # see https://flutter.dev/custom-fonts/#from-packages 72 | -------------------------------------------------------------------------------- /example/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility that Flutter provides. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter_test/flutter_test.dart'; 9 | 10 | void main() { 11 | testWidgets('Verify Platform version', (WidgetTester tester) async {}); 12 | } 13 | -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vagrant/ 3 | .sconsign.dblite 4 | .svn/ 5 | 6 | .DS_Store 7 | *.swp 8 | profile 9 | 10 | DerivedData/ 11 | build/ 12 | GeneratedPluginRegistrant.h 13 | GeneratedPluginRegistrant.m 14 | 15 | .generated/ 16 | 17 | *.pbxuser 18 | *.mode1v3 19 | *.mode2v3 20 | *.perspectivev3 21 | 22 | !default.pbxuser 23 | !default.mode1v3 24 | !default.mode2v3 25 | !default.perspectivev3 26 | 27 | xcuserdata 28 | 29 | *.moved-aside 30 | 31 | *.pyc 32 | *sync/ 33 | Icon? 34 | .tags* 35 | 36 | /Flutter/Generated.xcconfig 37 | /Flutter/flutter_export_environment.sh -------------------------------------------------------------------------------- /ios/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xx-li/disable_screenshots/b97d275bdacd76f573841efe5fac9a42f26aa77b/ios/Assets/.gitkeep -------------------------------------------------------------------------------- /ios/Classes/DisableScreenshotsPlugin.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface DisableScreenshotsPlugin : NSObject 4 | @end 5 | -------------------------------------------------------------------------------- /ios/Classes/DisableScreenshotsPlugin.m: -------------------------------------------------------------------------------- 1 | #import "DisableScreenshotsPlugin.h" 2 | #if __has_include() 3 | #import 4 | #else 5 | // Support project import fallback if the generated compatibility header 6 | // is not copied when this plugin is created as a library. 7 | // https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816 8 | #import "disable_screenshots-Swift.h" 9 | #endif 10 | 11 | @implementation DisableScreenshotsPlugin 12 | + (void)registerWithRegistrar:(NSObject*)registrar { 13 | [SwiftDisableScreenshotsPlugin registerWithRegistrar:registrar]; 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /ios/Classes/SwiftDisableScreenshotsPlugin.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | 4 | public class SwiftDisableScreenshotsPlugin: NSObject { 5 | var eventSink: FlutterEventSink? 6 | 7 | public static func register(with registrar: FlutterPluginRegistrar) { 8 | let instance = SwiftDisableScreenshotsPlugin() 9 | let methodChannel = FlutterMethodChannel( 10 | name: "com.devlxx.DisableScreenshots/disableScreenshots", 11 | binaryMessenger: registrar.messenger() 12 | ) 13 | registrar.addMethodCallDelegate(instance, channel: methodChannel) 14 | 15 | let channel = FlutterEventChannel( 16 | name: "com.devlxx.DisableScreenshots/observer", 17 | binaryMessenger: registrar.messenger() 18 | ) 19 | channel.setStreamHandler(instance) 20 | } 21 | 22 | @objc func callScreenshots() { 23 | eventSink!("") 24 | } 25 | } 26 | 27 | extension SwiftDisableScreenshotsPlugin: FlutterPlugin { 28 | public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { 29 | /* 30 | //iOS平台无法实现禁用截屏功能 31 | if call.method == "disableScreenshots" { 32 | if let arg = call.arguments as? Dictionary, let disable = arg["disable"] as? Bool { 33 | if disable { 34 | //禁用截屏 35 | } else { 36 | //允许截屏 37 | } 38 | } else { 39 | print("【SwiftDisableScreenshotsPlugin】disableScreenshots 收到错误参数") 40 | } 41 | } else { 42 | result(FlutterMethodNotImplemented) 43 | } 44 | */ 45 | result(FlutterMethodNotImplemented) 46 | } 47 | } 48 | 49 | extension SwiftDisableScreenshotsPlugin: FlutterStreamHandler { 50 | public func onListen(withArguments arguments: Any?, eventSink events: @escaping FlutterEventSink) -> FlutterError? { 51 | eventSink = events 52 | 53 | NotificationCenter.default.addObserver( 54 | self, 55 | selector: #selector(callScreenshots), 56 | name: UIApplication.userDidTakeScreenshotNotification, 57 | object: nil) 58 | 59 | return nil 60 | } 61 | 62 | public func onCancel(withArguments arguments: Any?) -> FlutterError? { 63 | NotificationCenter.default.removeObserver(self) 64 | eventSink = nil 65 | return nil 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /ios/disable_screenshots.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. 3 | # Run `pod lib lint disable_screenshots.podspec' to validate before publishing. 4 | # 5 | Pod::Spec.new do |s| 6 | s.name = 'disable_screenshots' 7 | s.version = '0.0.1' 8 | s.summary = 'A new flutter plugin project.' 9 | s.description = <<-DESC 10 | A new flutter plugin project. 11 | DESC 12 | s.homepage = 'http://example.com' 13 | s.license = { :file => '../LICENSE' } 14 | s.author = { 'Your Company' => 'email@example.com' } 15 | s.source = { :path => '.' } 16 | s.source_files = 'Classes/**/*' 17 | s.dependency 'Flutter' 18 | s.platform = :ios, '8.0' 19 | 20 | # Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported. 21 | s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' } 22 | s.swift_version = '5.0' 23 | end 24 | -------------------------------------------------------------------------------- /lib/disable_screenshots.dart: -------------------------------------------------------------------------------- 1 | library disable_screenshots; 2 | 3 | export 'src/disable_screenshots.dart'; 4 | -------------------------------------------------------------------------------- /lib/src/disable_screenshots.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter/services.dart'; 5 | 6 | import 'disable_screenshots_watarmark.dart'; 7 | 8 | class DisableScreenshots { 9 | static DisableScreenshots _singleton = DisableScreenshots._internal(); 10 | factory DisableScreenshots() { 11 | return _singleton; 12 | } 13 | DisableScreenshots._internal(); 14 | 15 | final MethodChannel _methodChannel = 16 | const MethodChannel("com.devlxx.DisableScreenshots/disableScreenshots"); 17 | final EventChannel _eventChannel = 18 | const EventChannel('com.devlxx.DisableScreenshots/observer'); 19 | 20 | OverlayEntry? _overlayEntry; 21 | Stream? _onScreenShots; 22 | 23 | /// 获取监听截屏动作的[Stream]。用法: 24 | /// 25 | /// ``` 26 | /// DisableScreenshots().onScreenShots.listen((event) { 27 | /// print("监听到了截屏动作"); 28 | /// }); 29 | /// ``` 30 | Stream get onScreenShots { 31 | if (_onScreenShots == null) { 32 | _onScreenShots = _eventChannel.receiveBroadcastStream(); 33 | } 34 | return _onScreenShots!; 35 | } 36 | 37 | /// 添加默认水印 38 | /// 39 | /// [watermark] 水印文案 40 | /// [rowCount] 水印文案每行显示的个数 41 | /// [columnCount] 水印文案每列显示的个数 42 | /// [textStyle] 水印文案的样式 43 | void addWatermark(BuildContext context, String watermark, 44 | {int rowCount = 3, int columnCount = 10, TextStyle? textStyle}) async { 45 | if (_overlayEntry != null) { 46 | _overlayEntry!.remove(); 47 | } 48 | OverlayState? overlayState = Overlay.of(context); 49 | _overlayEntry = OverlayEntry( 50 | builder: (context) => DisableScreenshotsWatarmark( 51 | rowCount: rowCount, 52 | columnCount: columnCount, 53 | text: watermark, 54 | textStyle: textStyle ?? 55 | const TextStyle( 56 | color: Color(0x08000000), 57 | fontSize: 18, 58 | decoration: TextDecoration.none), 59 | )); 60 | overlayState?.insert(_overlayEntry!); 61 | } 62 | 63 | /// 添加自定义水印。将[widget]覆盖在所有视图的最上层 64 | void addCustomWatermark(BuildContext context, Widget widget) { 65 | if (_overlayEntry != null) { 66 | _overlayEntry!.remove(); 67 | } 68 | OverlayState? overlayState = Overlay.of(context); 69 | _overlayEntry = OverlayEntry(builder: (context) => widget); 70 | overlayState?.insert(_overlayEntry!); 71 | } 72 | 73 | /// 移除水印 74 | void removeWatermark() async { 75 | if (_overlayEntry != null) { 76 | _overlayEntry!.remove(); 77 | _overlayEntry = null; 78 | } 79 | } 80 | 81 | /// 只支持安卓 82 | Future disableScreenshots(bool disable) async { 83 | if (Platform.isAndroid) { 84 | return await _methodChannel 85 | .invokeMethod("disableScreenshots", {"disable": disable}); 86 | } else { 87 | print('仅Android平台支持禁用屏幕截图'); 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /lib/src/disable_screenshots_watarmark.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'dart:math'; 3 | 4 | class DisableScreenshotsWatarmark extends StatelessWidget { 5 | final int rowCount; 6 | final int columnCount; 7 | final String text; 8 | final TextStyle textStyle; 9 | 10 | const DisableScreenshotsWatarmark({ 11 | Key? key, 12 | required this.rowCount, 13 | required this.columnCount, 14 | required this.text, 15 | required this.textStyle, 16 | }) : super(key: key); 17 | 18 | @override 19 | Widget build(BuildContext context) { 20 | return IgnorePointer( 21 | child: Container( 22 | child: Column( 23 | children: creatColumnWidgets(), 24 | )), 25 | ); 26 | } 27 | 28 | List creatRowWdiges() { 29 | List list = []; 30 | for (var i = 0; i < rowCount; i++) { 31 | final widget = Expanded( 32 | child: Center( 33 | child: Transform.rotate( 34 | angle: pi / 10, child: Text(text, style: textStyle)))); 35 | list.add(widget); 36 | } 37 | return list; 38 | } 39 | 40 | List creatColumnWidgets() { 41 | List list = []; 42 | for (var i = 0; i < columnCount; i++) { 43 | final widget = Expanded( 44 | child: Row( 45 | children: creatRowWdiges(), 46 | )); 47 | list.add(widget); 48 | } 49 | return list; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: disable_screenshots 2 | description: "Provides three related functions that disable screenshots. These are: screenshot monitoring, adding a watermark globally, disabling screenshots (only supports Android). 提供三个禁用截屏的相关功能。分别是:截屏监控、全局添加水印、禁用截屏(仅支持Android)" 3 | version: 0.2.0 4 | repository: https://github.com/xx-li/disable_screenshots 5 | homepage: https://blog.devlxx.com 6 | 7 | environment: 8 | sdk: ">=2.12.0 <3.0.0" 9 | flutter: ">=1.12.0" 10 | 11 | dependencies: 12 | flutter: 13 | sdk: flutter 14 | 15 | dev_dependencies: 16 | flutter_test: 17 | sdk: flutter 18 | 19 | # For information on the generic Dart part of this file, see the 20 | # following page: https://dart.dev/tools/pub/pubspec 21 | 22 | # The following section is specific to Flutter. 23 | flutter: 24 | # This section identifies this Flutter project as a plugin project. 25 | # The 'pluginClass' and Android 'package' identifiers should not ordinarily 26 | # be modified. They are used by the tooling to maintain consistency when 27 | # adding or updating assets for this project. 28 | plugin: 29 | platforms: 30 | android: 31 | package: com.devlxx.disable_screenshots 32 | pluginClass: DisableScreenshotsPlugin 33 | ios: 34 | pluginClass: DisableScreenshotsPlugin -------------------------------------------------------------------------------- /test/disable_screenshots_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/services.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:disable_screenshots/src/disable_screenshots.dart'; 4 | 5 | void main() { 6 | // const MethodChannel channel = MethodChannel('disable_screenshots'); 7 | 8 | // TestWidgetsFlutterBinding.ensureInitialized(); 9 | 10 | // setUp(() { 11 | // channel.setMockMethodCallHandler((MethodCall methodCall) async { 12 | // return '42'; 13 | // }); 14 | // }); 15 | 16 | // tearDown(() { 17 | // channel.setMockMethodCallHandler(null); 18 | // }); 19 | 20 | // test('getPlatformVersion', () async { 21 | // expect(await DisableScreenshots.platformVersion, '42'); 22 | // }); 23 | } 24 | --------------------------------------------------------------------------------