Skip to content

Commit a32484e

Browse files
committed
initial commit
0 parents  commit a32484e

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

AppDelegate.swift

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import UIKit
2+
import Flutter
3+
4+
5+
@UIApplicationMain
6+
@objc class AppDelegate: FlutterAppDelegate {
7+
override func application(
8+
_ application: UIApplication,
9+
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
10+
) -> Bool {
11+
self.window.makeSecure() // + add this line
12+
GeneratedPluginRegistrant.register(with: self)
13+
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
14+
}
15+
}
16+
17+
// + add this section
18+
19+
extension UIWindow {
20+
func makeSecure() {
21+
let field = UITextField()
22+
field.isSecureTextEntry = true
23+
self.addSubview(field)
24+
field.centerYAnchor.constraint(equalTo: self.centerYAnchor).isActive = true
25+
field.centerXAnchor.constraint(equalTo: self.centerXAnchor).isActive = true
26+
self.layer.superlayer?.addSublayer(field.layer)
27+
field.layer.sublayers?.first?.addSublayer(self.layer)
28+
}
29+
}

MainActivity.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.example.test // replace your packageName
2+
3+
import android.view.WindowManager.LayoutParams
4+
import io.flutter.embedding.android.FlutterActivity
5+
import io.flutter.embedding.engine.FlutterEngine
6+
7+
class MainActivity: FlutterActivity() {
8+
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
9+
window.addFlags(LayoutParams.FLAG_SECURE)
10+
super.configureFlutterEngine(flutterEngine)
11+
}
12+
}

README.md

Whitespace-only changes.

0 commit comments

Comments
 (0)