https://github.com/pouyamaroufi/secure-flutter-app
Block Screen Shots and Screen Record for iOS and Android in Flutter without using any package
https://github.com/pouyamaroufi/secure-flutter-app
android flutter ios kotlin screenreader screenshot security-tools swift
Last synced: 10 months ago
JSON representation
Block Screen Shots and Screen Record for iOS and Android in Flutter without using any package
- Host: GitHub
- URL: https://github.com/pouyamaroufi/secure-flutter-app
- Owner: pouyamaroufi
- License: mit
- Created: 2023-02-21T19:17:23.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-10-04T14:45:21.000Z (over 2 years ago)
- Last Synced: 2025-04-18T04:56:06.964Z (10 months ago)
- Topics: android, flutter, ios, kotlin, screenreader, screenshot, security-tools, swift
- Language: Swift
- Homepage:
- Size: 14.6 KB
- Stars: 15
- Watchers: 2
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# Make Your iOS and Android App Secure
## Block ScreenShots and Screen Recording without adding any packages in Flutter
:bulb: Notic: Only works on real Device | the codes dosen't works on simulator for both platform
## Android
Add this to `MainActivity` in android/app/src/main/kotlin/com/PackegeName/ProjectName
```kotlin
package com.example.test // replace your packageName
import android.view.WindowManager.LayoutParams
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
class MainActivity: FlutterActivity() {
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
window.addFlags(LayoutParams.FLAG_SECURE)
super.configureFlutterEngine(flutterEngine)
}
}
```
## iOS
Add this to `AppDelegate` in ios/Runner/AppDelegate.swift
```Swift
import UIKit
import Flutter
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
self.window.makeSecure() // + add this line
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
// + add this section
extension UIWindow {
func makeSecure() {
let field = UITextField()
field.isSecureTextEntry = true
self.addSubview(field)
field.centerYAnchor.constraint(equalTo: self.centerYAnchor).isActive = true
field.centerXAnchor.constraint(equalTo: self.centerXAnchor).isActive = true
self.layer.superlayer?.addSublayer(field.layer)
field.layer.sublayers?.first?.addSublayer(self.layer)
}
}
```