├── .gitignore ├── .idea ├── misc.xml ├── modules.xml ├── runConfigurations │ └── example_lib_main_dart.xml └── vcs.xml ├── .metadata ├── .vscode ├── launch.json └── settings.json ├── CHANGELOG.md ├── Gate_ios.jpg ├── LICENSE ├── README.md ├── android ├── .gitignore ├── .idea │ ├── caches │ │ └── build_file_checksums.ser │ ├── codeStyles │ │ └── Project.xml │ ├── gradle.xml │ ├── misc.xml │ ├── modules.xml │ └── runConfigurations.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── settings.gradle └── src │ └── main │ ├── AndroidManifest.xml │ └── kotlin │ └── org │ └── jezequel │ └── secure_application │ └── SecureApplicationPlugin.kt ├── android_appswitcher.JPG ├── example ├── .gitignore ├── .metadata ├── README.md ├── android │ ├── .gitignore │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── kotlin │ │ │ │ └── org │ │ │ │ │ └── jezequel │ │ │ │ │ ├── example │ │ │ │ │ └── MainActivity.kt │ │ │ │ │ └── secure_application_example │ │ │ │ │ └── MainActivity.kt │ │ │ └── res │ │ │ │ ├── drawable-v21 │ │ │ │ └── launch_background.xml │ │ │ │ ├── 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-night │ │ │ │ └── styles.xml │ │ │ │ └── values │ │ │ │ └── styles.xml │ │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── settings.gradle ├── flutter_01.png ├── 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.lock ├── pubspec.yaml ├── screenshot │ ├── gate_off.jpg │ └── gate_on.jpg ├── test │ └── widget_test.dart ├── web │ ├── favicon.png │ ├── icons │ │ ├── Icon-192.png │ │ └── Icon-512.png │ ├── index.html │ └── manifest.json └── windows │ ├── .gitignore │ ├── CMakeLists.txt │ ├── flutter │ ├── CMakeLists.txt │ ├── generated_plugin_registrant.cc │ ├── generated_plugin_registrant.h │ └── generated_plugins.cmake │ └── runner │ ├── CMakeLists.txt │ ├── Runner.rc │ ├── flutter_window.cpp │ ├── flutter_window.h │ ├── main.cpp │ ├── resource.h │ ├── resources │ └── app_icon.ico │ ├── run_loop.cpp │ ├── run_loop.h │ ├── runner.exe.manifest │ ├── utils.cpp │ ├── utils.h │ ├── win32_window.cpp │ └── win32_window.h ├── ios ├── .gitignore ├── Assets │ └── .gitkeep ├── Classes │ ├── SecureApplicationPlugin.h │ ├── SecureApplicationPlugin.m │ └── SwiftSecureApplicationPlugin.swift └── secure_application.podspec ├── lib ├── secure_application.dart ├── secure_application_controller.dart ├── secure_application_native.dart ├── secure_application_provider.dart ├── secure_application_state.dart ├── secure_application_web.dart └── secure_gate.dart ├── pubspec.lock ├── pubspec.yaml ├── test ├── secure_application_test.dart └── secure_window_test.dart └── windows ├── .gitignore ├── CMakeLists.txt ├── include └── secure_application │ └── secure_application_plugin.h └── secure_application_plugin.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .dart_tool/ 3 | 4 | .packages 5 | .pub/ 6 | 7 | build/ 8 | 9 | # IntelliJ 10 | *.iml 11 | .idea/workspace.xml 12 | .idea/tasks.xml 13 | .idea/gradle.xml 14 | .idea/assetWizardSettings.xml 15 | .idea/dictionaries 16 | .idea/libraries 17 | .idea/caches 18 | 19 | *.cxx 20 | app/.cxx/* 21 | 22 | #Ignore thumbnails created by Windows 23 | Thumbs.db 24 | #Ignore files built by Visual Studio 25 | *.obj 26 | *.exe 27 | *.pdb 28 | *.user 29 | *.aps 30 | *.pch 31 | *.vspscc 32 | *_i.c 33 | *_p.c 34 | *.ncb 35 | *.suo 36 | *.tlb 37 | *.tlh 38 | *.bak 39 | *.cache 40 | *.ilk 41 | *.log 42 | [Bb]in 43 | [Dd]ebug*/ 44 | *.lib 45 | *.sbr 46 | obj/ 47 | [Rr]elease*/ 48 | _ReSharper*/ 49 | [Tt]est[Rr]esult* 50 | .vs/ 51 | #Nuget packages folder 52 | packages/ 53 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | -------------------------------------------------------------------------------- /.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/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.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: 0b8abb4724aa590dd0f429683339b1e045a1594d 8 | channel: stable 9 | 10 | project_type: plugin 11 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "secure_application", 9 | "request": "launch", 10 | "type": "dart" 11 | }, 12 | { 13 | "name": "secure_application (profile mode)", 14 | "request": "launch", 15 | "type": "dart", 16 | "flutterMode": "profile" 17 | }, 18 | { 19 | "name": "example", 20 | "cwd": "example", 21 | "request": "launch", 22 | "type": "dart" 23 | }, 24 | { 25 | "name": "example (profile mode)", 26 | "cwd": "example", 27 | "request": "launch", 28 | "type": "dart", 29 | "flutterMode": "profile" 30 | } 31 | ] 32 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "istream": "cpp", 4 | "memory": "cpp", 5 | "tuple": "cpp", 6 | "type_traits": "cpp", 7 | "algorithm": "cpp", 8 | "any": "cpp", 9 | "atomic": "cpp", 10 | "bit": "cpp", 11 | "cctype": "cpp", 12 | "chrono": "cpp", 13 | "clocale": "cpp", 14 | "cmath": "cpp", 15 | "compare": "cpp", 16 | "concepts": "cpp", 17 | "cstddef": "cpp", 18 | "cstdint": "cpp", 19 | "cstdio": "cpp", 20 | "cstdlib": "cpp", 21 | "cstring": "cpp", 22 | "ctime": "cpp", 23 | "cwchar": "cpp", 24 | "exception": "cpp", 25 | "functional": "cpp", 26 | "initializer_list": "cpp", 27 | "ios": "cpp", 28 | "iosfwd": "cpp", 29 | "iostream": "cpp", 30 | "iterator": "cpp", 31 | "limits": "cpp", 32 | "list": "cpp", 33 | "map": "cpp", 34 | "new": "cpp", 35 | "optional": "cpp", 36 | "ostream": "cpp", 37 | "ratio": "cpp", 38 | "set": "cpp", 39 | "sstream": "cpp", 40 | "stdexcept": "cpp", 41 | "streambuf": "cpp", 42 | "string": "cpp", 43 | "system_error": "cpp", 44 | "typeinfo": "cpp", 45 | "unordered_map": "cpp", 46 | "utility": "cpp", 47 | "variant": "cpp", 48 | "vector": "cpp", 49 | "xfacet": "cpp", 50 | "xhash": "cpp", 51 | "xiosbase": "cpp", 52 | "xlocale": "cpp", 53 | "xlocinfo": "cpp", 54 | "xlocnum": "cpp", 55 | "xmemory": "cpp", 56 | "xstddef": "cpp", 57 | "xstring": "cpp", 58 | "xtr1common": "cpp", 59 | "xtree": "cpp", 60 | "xutility": "cpp" 61 | }, 62 | "java.configuration.updateBuildConfiguration": "automatic" 63 | } -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 4.1.0 2 | 3 | * Remove registrar This makes the plugin flutter 3.29.0 ready (thanks @Bassiuz ) 4 | * Set Java SDK version to avoir issue with latest android studio 5 | * fix sample application 6 | 7 | ## 4.0.0 8 | 9 | * Migrate to flutter 3.0 10 | * Upgrade rxdart (thanks @ariefwijaya ) 11 | * Upgrade android dependencies 12 | * [BUGFIX] Null check fix (thanks @WeiCongcong ) 13 | 14 | 15 | ## 3.8.0 16 | 17 | * [BUGFIX] No signature of method: build_…android() applicable for argument types: (build_…_run_closure2) ( #24 ) thanks @ghostman2013 18 | * [BUGFIX] Fix null safety 19 | 20 | ## 3.7.3 21 | 22 | * [BUGFIX] nativeRemoveDelay is null and that makes the app crash ( #16 ) 23 | 24 | ## 3.7.2 25 | 26 | * [BUGFIX] Fix a null safety issue (thanks @abhinandval and @lubritto ) 27 | 28 | ## 3.7.1 29 | 30 | * [WINDOWS] No also lock when user go to windows lock screen/switch user 31 | 32 | ## 3.7.0 33 | 34 | * Windows support (minimize window will lock) 35 | 36 | ## 3.6.0 37 | 38 | * Null safety 39 | * Web support 40 | 41 | ## 3.5.2 42 | 43 | * Small improvements to IOS Code 44 | 45 | ## 3.5.1 46 | 47 | * Documentation tips 48 | 49 | ## 3.5.0 50 | 51 | * Upgrade to RxDart 0.24.0 52 | 53 | ## 3.4.1 54 | 55 | * Opacity is now propagated to IOS protection on task switcher 56 | 57 | ## 3.3.2 58 | 59 | * Fix not implemented exception on Android when you exit the app 60 | 61 | ## 3.3.1 62 | 63 | * Fix if you wanted to start the application locked. issue: https://github.com/neckaros/secure_application/issues/1 64 | 65 | ## 3.3.0 66 | 67 | * New behavior stream for lock/unlock event so you can react to them in your application 68 | 69 | ## 3.2.0 70 | 71 | * iOS works on iPad when you rotate after closing 72 | 73 | ## 3.1.2 74 | 75 | * iOS fix 76 | 77 | ## 3.1.1 78 | 79 | * require swift 4.2+ 80 | 81 | ## 3.0.7 82 | 83 | * allow to configure nativeRemoveDelay in secure_gate to let longer app time to start especially on iOS 84 | 85 | ## 3.0.6 86 | 87 | * iOS new bringSubview(toFront:) instead of deprecated metho 88 | * pause during needunlock to prevent ios unlock loop when using faceid 89 | 90 | ## 3.0.3 91 | 92 | * new authenticated information 93 | * autenticationEvents is now a BehaviorSubject stream 94 | 95 | ## 3.0.0 96 | 97 | * Rename package 98 | 99 | ## 1.0.0 100 | 101 | * Working on iOS and Android 102 | 103 | ## 0.0.1 104 | 105 | * Initial release 106 | -------------------------------------------------------------------------------- /Gate_ios.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/Gate_ios.jpg -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Arnaud JEZEQUEL 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. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **previously nammed secure_window** 2 | 3 | # secure_application 4 | 5 | This plugin allow you to protect your application content from view on demand 6 | 7 | 8 | 9 | Pluggin in iOS is in swift 10 | 11 | Pluggin in Android is in Kotlin / AndroidX libraries 12 | 13 | Pluggin is also working for web 14 | 15 | Plugin work for windows (will lock when you minimize the window and lock screen) 16 | 17 | ## Usage 18 | 19 | ### Installation 20 | 21 | Add `secure_application` as a dependency in your pubspec.yaml file ([what?](https://pub.dev/packages/secure_application#-installing-tab-)). 22 | 23 | ### Import 24 | 25 | Import secure_application: 26 | ```dart 27 | import 'package:secure_application/secure_application.dart'; 28 | ``` 29 | 30 | Add a top level SecureApplication 31 | ```dart 32 | SecureApplication( 33 | onNeedUnlock: (secure) => print( 34 | 'need unlock maybe use biometric to confirm and then use sercure.unlock()'), 35 | child: MyAppContent(), 36 | ) 37 | ``` 38 | 39 | Put the content you want to protect in a SecureGate (could be the whole app) 40 | ```dart 41 | SecureGate( 42 | blurr: 5, 43 | lockedBuilder: (context, secureNotifier) => Center( 44 | child: RaisedButton( 45 | child: Text('test'), 46 | onPressed: () => secureNotifier.unlock(), 47 | )), 48 | child: YouProtectedWidget(), 49 | ) 50 | ``` 51 | 52 | ## Tips 53 | ### Placement 54 | Best place to add the secure application is directly **inside** the MaterialApp by using its builder: 55 | ```dart 56 | class MyApp extends StatelessWidget { 57 | final navigatorKey = GlobalKey(); 58 | @override 59 | Widget build(BuildContext context) => MaterialApp( 60 | navigatorKey: navigatorKey, 61 | localizationsDelegates: [ 62 | DefaultMaterialLocalizations.delegate, 63 | DefaultCupertinoLocalizations.delegate, 64 | DefaultWidgetsLocalizations.delegate, 65 | ], 66 | // debugShowCheckedModeBanner: false, 67 | title: 'Your Fancy App', 68 | darkTheme: YourDarkTheme, 69 | theme: YourTheme, 70 | onGenerateRoute: _generateRoute, 71 | builder: (context, child) => SecureApplication( 72 | nativeRemoveDelay: 800, 73 | onNeedUnlock: (secureApplicationController) async { 74 | var authResult = await auth( 75 | askValidation: () => askValidation(context, child), 76 | validationForFaceOnly: false); 77 | if (authResult) { 78 | secureApplicationController.authSuccess(unlock: true); 79 | } else { 80 | secureApplicationController.authFailed(unlock: true); 81 | secureApplicationController.open(); 82 | } 83 | return null; 84 | }, 85 | child: child, 86 | ), 87 | ); 88 | 89 | Route _generateRoute(RouteSettings settings) { 90 | switch (settings.name) { 91 | case '/splash': 92 | return MaterialPageRoute(builder: (context) => Container()); 93 | default: 94 | return MaterialPageRoute( 95 | builder: (context) => 96 | SecureGate(blurr: 60, opacity: 0.8, child: DecisionPage())); 97 | } 98 | } 99 | 100 | Future askValidation(BuildContext context, Widget navigator) async { 101 | if (navigator is Navigator) { 102 | final context = navigatorKey.currentState.overlay.context; 103 | return await showDialog( 104 | context: context, 105 | barrierDismissible: false, // user must tap button! 106 | builder: (BuildContext context) { 107 | return CupertinoAlertDialog( 108 | title: Text('Unlock app content'), 109 | content: Text( 110 | 'Do you wan to unlock the application content? Clicking no will secure the app'), 111 | actions: [ 112 | CupertinoDialogAction( 113 | isDefaultAction: true, 114 | child: Text('No'), 115 | onPressed: () { 116 | Navigator.of(context).pop(false); 117 | }, 118 | ), 119 | CupertinoDialogAction( 120 | child: Text('Yes'), 121 | onPressed: () { 122 | Navigator.of(context).pop(true); 123 | }, 124 | ), 125 | ], 126 | ); 127 | }, 128 | ); 129 | } 130 | } 131 | } 132 | ``` 133 | 134 | Notice 3 importants part here: 135 | * Secure application is in MaterialApp/Builder so just above your app naviagator 136 | * I wrap the route i want to protect in onGenerateRoute with a **SecureGate** but you could put it anywhare you want if you only want to protect part of your page 137 | * Ask validation will display a dialog above everything to ask is you want to unlock app or not 138 | 139 | ### react to failed auth 140 | ```dart 141 | class SecureReacting extends StatefulWidget { 142 | @override 143 | _SecureReactingState createState() => _SecureReactingState(); 144 | } 145 | 146 | class _SecureReactingState extends State { 147 | bool locked = false; 148 | StreamSubscription _authEventsSub; 149 | @override 150 | void initState() { 151 | super.initState(); 152 | var lockController = SecureApplicationProvider.of(context, listen: false); 153 | _authEventsSub = lockController.authenticationEvents 154 | .where((s) => s == SecureApplicationAuthenticationStatus.FAILED) 155 | .listen((_) => lock()); 156 | } 157 | 158 | void lock() { 159 | if (mounted) { 160 | setState(() => locked = true); 161 | Navigator.of(context).pop(); 162 | } 163 | } 164 | 165 | @override 166 | void dispose() { 167 | _authEventsSub?.cancel(); 168 | super.dispose(); 169 | } 170 | 171 | @override 172 | Widget build(BuildContext context) { 173 | return locked ? Container() : Container(); 174 | } 175 | } 176 | ``` 177 | 178 | Notice 2 importants part here: 179 | * You are subscribing to a stream so don't forget to unsubscribe in onDispose 180 | * Since your animation from pop can take some time you might want also to have a locked variable here to display different content during transition 181 | 182 | 183 | 184 | ## API Docs 185 | [API Reference](https://pub.dev/documentation/secure_application/latest/) 186 | 187 | ## Basic understanding 188 | 189 | The library is mainly controller via the [SecureApplicationController](https://pub.dev/documentation/secure_application/latest/secure_application_controller/SecureApplicationController-class.html) which can be 190 | 191 | ### secured 192 | if the user switch app or leave app the content will not be visible in the app switcher 193 | and when it goes back to the app it will **lock** it 194 | 195 | ### locked 196 | the child of the **SecureGate**s will be hidden bellow the blurry barrier 197 | 198 | ### paused 199 | even if secured **SecureGate**s will not activate when user comes back to the app 200 | 201 | ### authenticated 202 | last authentication status. To help you manage visibility of some elements of your UI 203 | depending on auth status 204 | 205 | * **secureApplicationController.authFailed()** will set it to **false** 206 | * **secureApplicationController.authLogout()** will set it to **false** 207 | * **secureApplicationController.authSuccess()** will set it to **true** 208 | 209 | You could use the authenticationEvents for the same purpose as it is a BehaviorSubject stream 210 | 211 | ### Streams 212 | There is two different BehaviorStream (emit last value when you subscribe): 213 | 214 | * **authenticationEvents**: When there is a successful or unsucessful authentification (you can use it for example to clean your app if authentification is not successful) 215 | * **lockEvents**: Will be called when the application lock or unlock. Usefull for example to pause media when the app lock 216 | 217 | ## Example 218 | 219 | Look at example app to see a use case 220 | 221 | ## Authentication 222 | 223 | This tool does not impose a way to authenticate the user to give them back access to their content 224 | 225 | You are free to use your own Widget/Workflow to allow user to see their content once locked (cf **SecureApplication** widget argument [onNeedUnlock](https://pub.dev/documentation/secure_application/latest/secure_application/SecureApplication/onNeedUnlock.html)) 226 | 227 | Therefore you can use any method you like: 228 | * Your own Widget for code Authentication 229 | * biometrics with the [local_auth](https://pub.dev/packages/local_auth) package 230 | * ... 231 | 232 | ## Android 233 | On Android as soon as you **secure** the application the user will not be able to capture the screen in the app (even if unlocked) 234 | We might give an option to allow screenshot as an option if need arise 235 | 236 | ## iOS 237 | Contrary to Android we create a native frosted view over your app content so that content is not visible in the app switcher. 238 | When the user gets back to the app we wait for ~500ms to remove this view to allow time for the app to woke and flutter gate to draw 239 | 240 | # Widgets 241 | 242 | ## SecureApplication 243 | [Api Doc](https://pub.dev/documentation/secure_application/latest/secure_application/SecureApplication-class.html) 244 | this widget is **required** and need to be a parent of any Gate 245 | it provides to its descendant a SecureApplicationProvider that allow you to secure or open the application 246 | 247 | You can pass you own initialized SecureApplicationController if you want to set default values 248 | 249 | ## SecureGate 250 | [Api Doc](https://pub.dev/documentation/secure_application/latest/secure_gate/SecureGate-class.html) 251 | The **child** of this widget will be below a blurry barrier (control the amount of **blurr** and **opacity** with its arguments) 252 | if the provided SecureApplicationController is **locked** 253 | 254 | # Native workings 255 | 256 | ## Android 257 | When **locked** we set the secure flag to true 258 | ```kotlin 259 | activity?.window?.addFlags(LayoutParams.FLAG_SECURE) 260 | ``` 261 | When **opened** we remove the secure flag 262 | ```kotlin 263 | activity?.window?.clearFlags(LayoutParams.FLAG_SECURE) 264 | ``` 265 | 266 | ## iOS 267 | When app will become inactive we add a top view with a blurr filter 268 | We remove this app 500ms after the app become active to avoid your content form being breifly visible 269 | 270 | # Because we all want to see code in a Readme 271 | ```dart 272 | Widget build(BuildContext context) { 273 | var width = MediaQuery.of(context).size.width * 0.8; 274 | return MaterialApp( 275 | home: SecureApplication( 276 | onNeedUnlock: (secure) async { 277 | print( 278 | 'need unlock maybe use biometric to confirm and then sercure.unlock() or you can use the lockedBuilder'); 279 | // var authResult = authMyUser(); 280 | // if (authResul) { 281 | // secure.unlock(); 282 | // return SecureApplicationAuthenticationStatus.SUCCESS; 283 | //} 284 | // else { 285 | // return SecureApplicationAuthenticationStatus.FAILED; 286 | //} 287 | return null; 288 | }, 289 | onAuthenticationFailed: () async { 290 | // clean you data 291 | setState(() { 292 | failedAuth = true; 293 | }); 294 | print('auth failed'); 295 | }, 296 | onAuthenticationSucceed: () async { 297 | // clean you data 298 | 299 | setState(() { 300 | failedAuth = false; 301 | }); 302 | print('auth success'); 303 | }, 304 | child: SecureGate( 305 | blurr: blurr, 306 | opacity: opacity, 307 | lockedBuilder: (context, secureNotifier) => Center( 308 | child: Column( 309 | mainAxisAlignment: MainAxisAlignment.center, 310 | children: [ 311 | RaisedButton( 312 | child: Text('UNLOCK'), 313 | onPressed: () => secureNotifier.authSuccess(unlock: true), 314 | ), 315 | RaisedButton( 316 | child: Text('FAIL AUTHENTICATION'), 317 | onPressed: () => secureNotifier.authFailed(unlock: true), 318 | ), 319 | ], 320 | )), 321 | child: Scaffold( 322 | appBar: AppBar( 323 | title: const Text('Secure Window Example'), 324 | ), 325 | body: Center( 326 | child: Builder(builder: (context) { 327 | var valueNotifier = SecureApplicationProvider.of(context); 328 | return ListView( 329 | children: [ 330 | Text('This is secure content'), 331 | RaisedButton( 332 | onPressed: () => valueNotifier.secure(), 333 | child: Text('secure'), 334 | ), 335 | RaisedButton( 336 | onPressed: () => valueNotifier.open(), 337 | child: Text('open'), 338 | ), 339 | if (failedAuth == null) 340 | Text( 341 | 'Lock the app then switch to another app and come back'), 342 | if (failedAuth != null) 343 | failedAuth 344 | ? Text( 345 | 'Auth failed we cleaned sensitive data', 346 | style: TextStyle(color: Colors.red), 347 | ) 348 | : Text( 349 | 'Auth success', 350 | style: TextStyle(color: Colors.green), 351 | ), 352 | FlutterLogo( 353 | size: width, 354 | ), 355 | RaisedButton( 356 | onPressed: () => valueNotifier.lock(), 357 | child: Text('manually lock'), 358 | ), 359 | Padding( 360 | padding: const EdgeInsets.all(8.0), 361 | child: Row( 362 | children: [ 363 | Text('Blurr:'), 364 | Expanded( 365 | child: Slider( 366 | value: blurr, 367 | min: 0, 368 | max: 100, 369 | onChanged: (v) => setState(() => blurr = v)), 370 | ), 371 | Text(blurr.floor().toString()), 372 | ], 373 | ), 374 | ), 375 | Padding( 376 | padding: const EdgeInsets.all(8.0), 377 | child: Row( 378 | children: [ 379 | Text('opacity:'), 380 | Expanded( 381 | child: Slider( 382 | value: opacity, 383 | min: 0, 384 | max: 1, 385 | onChanged: (v) => setState(() => opacity = v)), 386 | ), 387 | Text((opacity * 100).floor().toString() + "%"), 388 | ], 389 | ), 390 | ), 391 | ], 392 | ); 393 | }), 394 | ), 395 | ), 396 | ), 397 | ), 398 | ); 399 | } 400 | ``` -------------------------------------------------------------------------------- /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/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/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 | 17 | 18 | -------------------------------------------------------------------------------- /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/build.gradle: -------------------------------------------------------------------------------- 1 | group 'org.jezequel.secure_application' 2 | version '1.0-SNAPSHOT' 3 | 4 | rootProject.allprojects { 5 | repositories { 6 | google() 7 | mavenCentral() 8 | } 9 | } 10 | 11 | apply plugin: 'com.android.library' 12 | apply plugin: 'kotlin-android' 13 | 14 | android { 15 | namespace "org.jezequel.secure_application" 16 | compileSdkVersion 31 17 | 18 | compileOptions { 19 | sourceCompatibility JavaVersion.VERSION_11 20 | targetCompatibility JavaVersion.VERSION_11 21 | } 22 | kotlinOptions { 23 | jvmTarget = 11 24 | } 25 | 26 | sourceSets { 27 | main.java.srcDirs += 'src/main/kotlin' 28 | } 29 | 30 | defaultConfig { 31 | minSdkVersion 16 32 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 33 | } 34 | lintOptions { 35 | disable 'InvalidPackage' 36 | } 37 | dependencies { 38 | compileOnly rootProject.findProject(":flutter_plugin_android_lifecycle") 39 | } 40 | } 41 | 42 | dependencies { 43 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.24" 44 | } 45 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.enableR8=true 3 | android.useAndroidX=true 4 | android.enableJetifier=true -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 10 23:10:36 CEST 2024 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | 2 | pluginManagement { 3 | def flutterSdkPath = { 4 | def properties = new Properties() 5 | file("local.properties").withInputStream { properties.load(it) } 6 | def flutterSdkPath = properties.getProperty("flutter.sdk") 7 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 8 | return flutterSdkPath 9 | }() 10 | 11 | includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") 12 | 13 | repositories { 14 | google() 15 | mavenCentral() 16 | gradlePluginPortal() 17 | } 18 | } 19 | 20 | plugins { 21 | id "dev.flutter.flutter-plugin-loader" version "1.0.0" 22 | id "com.android.application" version "7.3.0" apply false 23 | id "org.jetbrains.kotlin.android" version "1.5.21" apply false 24 | } 25 | 26 | include ":app" 27 | 28 | rootProject.name = 'secure_application' -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /android/src/main/kotlin/org/jezequel/secure_application/SecureApplicationPlugin.kt: -------------------------------------------------------------------------------- 1 | package org.jezequel.secure_application 2 | 3 | import android.app.Activity 4 | import android.util.Log 5 | import androidx.annotation.NonNull; 6 | import io.flutter.embedding.engine.plugins.FlutterPlugin 7 | import io.flutter.plugin.common.MethodCall 8 | import io.flutter.plugin.common.MethodChannel 9 | import io.flutter.plugin.common.MethodChannel.MethodCallHandler 10 | import io.flutter.plugin.common.MethodChannel.Result 11 | import android.view.WindowManager.LayoutParams; 12 | import androidx.lifecycle.Lifecycle 13 | import io.flutter.embedding.engine.plugins.activity.ActivityAware 14 | import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding 15 | import io.flutter.embedding.engine.plugins.lifecycle.FlutterLifecycleAdapter; 16 | import androidx.lifecycle.LifecycleObserver 17 | import androidx.lifecycle.OnLifecycleEvent 18 | 19 | 20 | /** SecureApplicationPlugin */ 21 | public class SecureApplicationPlugin: FlutterPlugin, MethodCallHandler, ActivityAware, LifecycleObserver { 22 | private var activity: Activity? = null 23 | lateinit var instance: SecureApplicationPlugin 24 | 25 | override fun onDetachedFromActivity() { 26 | // not used for now but might be used to add some features in the future 27 | } 28 | 29 | override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) { 30 | if (::instance.isInitialized) 31 | instance.activity = binding.activity 32 | else 33 | this.activity = binding.activity 34 | val lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(binding) as Lifecycle 35 | lifecycle.addObserver(this) 36 | } 37 | 38 | override fun onAttachedToActivity(binding: ActivityPluginBinding) { 39 | if (::instance.isInitialized) 40 | instance.activity = binding.activity 41 | else 42 | this.activity = binding.activity 43 | val lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(binding) as Lifecycle 44 | lifecycle.addObserver(this) 45 | } 46 | 47 | override fun onDetachedFromActivityForConfigChanges() { 48 | // not used for now but might be used to add some features in the future 49 | } 50 | 51 | 52 | override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { 53 | instance = SecureApplicationPlugin() 54 | val channel = MethodChannel(flutterPluginBinding.binaryMessenger, "secure_application") 55 | channel.setMethodCallHandler(instance) 56 | } 57 | 58 | @OnLifecycleEvent(Lifecycle.Event.ON_RESUME) 59 | fun connectListener() { 60 | // not used for now but might be used to add some features in the future 61 | } 62 | 63 | override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) { 64 | if (call.method == "secure") { 65 | activity?.window?.addFlags(LayoutParams.FLAG_SECURE) 66 | result.success(true) 67 | } else if (call.method == "open") { 68 | activity?.window?.clearFlags(LayoutParams.FLAG_SECURE) 69 | result.success(true) 70 | } else { 71 | result.success(true) 72 | } 73 | } 74 | 75 | override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) { 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /android_appswitcher.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/android_appswitcher.JPG -------------------------------------------------------------------------------- /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 | # Exceptions to above rules. 37 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 38 | -------------------------------------------------------------------------------- /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: 0b8abb4724aa590dd0f429683339b1e045a1594d 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # secure_application_example 2 | 3 | Demonstrates how to use the secure_application plugin. 4 | 5 | ## Getting Started 6 | 7 | -------------------------------------------------------------------------------- /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/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "com.android.application" 3 | id "kotlin-android" 4 | id "dev.flutter.flutter-gradle-plugin" 5 | } 6 | 7 | def localProperties = new Properties() 8 | def localPropertiesFile = rootProject.file('local.properties') 9 | if (localPropertiesFile.exists()) { 10 | localPropertiesFile.withReader('UTF-8') { reader -> 11 | localProperties.load(reader) 12 | } 13 | } 14 | 15 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 16 | if (flutterVersionCode == null) { 17 | flutterVersionCode = '1' 18 | } 19 | 20 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 21 | if (flutterVersionName == null) { 22 | flutterVersionName = '1.0' 23 | } 24 | 25 | 26 | android { 27 | namespace "org.jezequel.secure_application_example" 28 | compileSdkVersion 35 29 | 30 | compileOptions { 31 | sourceCompatibility JavaVersion.VERSION_17 32 | targetCompatibility JavaVersion.VERSION_17 33 | } 34 | kotlinOptions { 35 | jvmTarget = 17 36 | } 37 | 38 | sourceSets { 39 | main.java.srcDirs += 'src/main/kotlin' 40 | } 41 | 42 | lintOptions { 43 | disable 'InvalidPackage' 44 | } 45 | 46 | defaultConfig { 47 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 48 | applicationId "org.jezequel.secure_application_example" 49 | minSdkVersion flutter.minSdkVersion 50 | targetSdkVersion 30 51 | versionCode flutterVersionCode.toInteger() 52 | versionName flutterVersionName 53 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 54 | } 55 | 56 | buildTypes { 57 | release { 58 | // TODO: Add your own signing config for the release build. 59 | // Signing with the debug keys for now, so `flutter run --release` works. 60 | signingConfig signingConfigs.debug 61 | } 62 | } 63 | } 64 | 65 | flutter { 66 | source '../..' 67 | } 68 | 69 | dependencies { 70 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 71 | testImplementation 'junit:junit:4.13.2' 72 | androidTestImplementation 'androidx.test:runner:1.4.0' 73 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' 74 | } 75 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 8 | 12 | 19 | 20 | 21 | 22 | 23 | 24 | 26 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /example/android/app/src/main/kotlin/org/jezequel/example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package org.jezequel.example 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /example/android/app/src/main/kotlin/org/jezequel/secure_application_example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package org.jezequel.secure_application_example 2 | 3 | import androidx.annotation.NonNull; 4 | import io.flutter.embedding.android.FlutterActivity 5 | import io.flutter.embedding.engine.FlutterEngine 6 | import io.flutter.plugins.GeneratedPluginRegistrant 7 | 8 | class MainActivity: FlutterActivity() { 9 | override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) { 10 | GeneratedPluginRegistrant.registerWith(flutterEngine); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /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/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/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/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/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/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/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/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/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/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | allprojects { 2 | repositories { 3 | google() 4 | mavenCentral() 5 | } 6 | } 7 | 8 | ext.kotlin_version = '1.9.23' // Latest version as of March 2025 9 | 10 | 11 | rootProject.buildDir = '../build' 12 | subprojects { 13 | project.buildDir = "${rootProject.buildDir}/${project.name}" 14 | } 15 | subprojects { 16 | project.evaluationDependsOn(':app') 17 | } 18 | 19 | tasks.register("clean", Delete) { 20 | delete rootProject.buildDir 21 | } 22 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | org.gradle.java.home=C:\\Program Files\\Android\\Android Studio\\jbr 3 | android.useAndroidX=true 4 | android.enableJetifier=true -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 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-8.10.2-all.zip 7 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | def flutterSdkPath = { 3 | def properties = new Properties() 4 | file("local.properties").withInputStream { properties.load(it) } 5 | def flutterSdkPath = properties.getProperty("flutter.sdk") 6 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 7 | return flutterSdkPath 8 | }() 9 | 10 | includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") 11 | 12 | repositories { 13 | google() 14 | mavenCentral() 15 | gradlePluginPortal() 16 | } 17 | } 18 | 19 | plugins { 20 | id "dev.flutter.flutter-plugin-loader" version "1.0.0" 21 | id "com.android.application" version "8.3.2" apply false 22 | id "org.jetbrains.kotlin.android" version "2.0.20" apply false 23 | } 24 | 25 | include ":app" -------------------------------------------------------------------------------- /example/flutter_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/example/flutter_01.png -------------------------------------------------------------------------------- /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/ephemeral/ 22 | Flutter/app.flx 23 | Flutter/app.zip 24 | Flutter/flutter_assets/ 25 | Flutter/flutter_export_environment.sh 26 | ServiceDefinitions.json 27 | Runner/GeneratedPluginRegistrant.* 28 | 29 | # Exceptions to above rules. 30 | !default.mode1v3 31 | !default.mode2v3 32 | !default.pbxuser 33 | !default.perspectivev3 34 | -------------------------------------------------------------------------------- /example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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 | - Flutter (1.0.0) 3 | - secure_application (0.0.1): 4 | - Flutter 5 | 6 | DEPENDENCIES: 7 | - Flutter (from `Flutter`) 8 | - secure_application (from `.symlinks/plugins/secure_application/ios`) 9 | 10 | EXTERNAL SOURCES: 11 | Flutter: 12 | :path: Flutter 13 | secure_application: 14 | :path: ".symlinks/plugins/secure_application/ios" 15 | 16 | SPEC CHECKSUMS: 17 | Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c 18 | secure_application: 27d424e8c2e770f63e38e280b5a51f921aa9b0c8 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 = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 11 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 12 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 13 | 8E43EF862839B926CBAC1019 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 04D1D04787CEFF94F60FE798 /* Pods_Runner.framework */; }; 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 | 04D1D04787CEFF94F60FE798 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 34 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 35 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 36 | 17B764A4A20FF79E31940E05 /* 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 = ""; }; 37 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 38 | 502301990184875FCF6A4E97 /* 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 = ""; }; 39 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 40 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 41 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 42 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 43 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 44 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 45 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 46 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 47 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 48 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 49 | DA74D18BDF35836DDB8EDDAB /* 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 | 8E43EF862839B926CBAC1019 /* Pods_Runner.framework in Frameworks */, 58 | ); 59 | runOnlyForDeploymentPostprocessing = 0; 60 | }; 61 | /* End PBXFrameworksBuildPhase section */ 62 | 63 | /* Begin PBXGroup section */ 64 | 93B55507692329ED2FA7F33D /* Frameworks */ = { 65 | isa = PBXGroup; 66 | children = ( 67 | 04D1D04787CEFF94F60FE798 /* 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 | FDF0185A10E9EEAA1E282412 /* Pods */, 90 | 93B55507692329ED2FA7F33D /* 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 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 110 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 111 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, 112 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, 113 | ); 114 | path = Runner; 115 | sourceTree = ""; 116 | }; 117 | FDF0185A10E9EEAA1E282412 /* Pods */ = { 118 | isa = PBXGroup; 119 | children = ( 120 | DA74D18BDF35836DDB8EDDAB /* Pods-Runner.debug.xcconfig */, 121 | 502301990184875FCF6A4E97 /* Pods-Runner.release.xcconfig */, 122 | 17B764A4A20FF79E31940E05 /* Pods-Runner.profile.xcconfig */, 123 | ); 124 | name = Pods; 125 | path = Pods; 126 | sourceTree = ""; 127 | }; 128 | /* End PBXGroup section */ 129 | 130 | /* Begin PBXNativeTarget section */ 131 | 97C146ED1CF9000F007C117D /* Runner */ = { 132 | isa = PBXNativeTarget; 133 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; 134 | buildPhases = ( 135 | BD757E512072C34CADA60790 /* [CP] Check Pods Manifest.lock */, 136 | 9740EEB61CF901F6004384FC /* Run Script */, 137 | 97C146EA1CF9000F007C117D /* Sources */, 138 | 97C146EB1CF9000F007C117D /* Frameworks */, 139 | 97C146EC1CF9000F007C117D /* Resources */, 140 | 9705A1C41CF9048500538489 /* Embed Frameworks */, 141 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 142 | 17C1869A00BD25F27C547507 /* [CP] Embed Pods Frameworks */, 143 | ); 144 | buildRules = ( 145 | ); 146 | dependencies = ( 147 | ); 148 | name = Runner; 149 | productName = Runner; 150 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */; 151 | productType = "com.apple.product-type.application"; 152 | }; 153 | /* End PBXNativeTarget section */ 154 | 155 | /* Begin PBXProject section */ 156 | 97C146E61CF9000F007C117D /* Project object */ = { 157 | isa = PBXProject; 158 | attributes = { 159 | LastUpgradeCheck = 1020; 160 | ORGANIZATIONNAME = ""; 161 | TargetAttributes = { 162 | 97C146ED1CF9000F007C117D = { 163 | CreatedOnToolsVersion = 7.3.1; 164 | LastSwiftMigration = 1100; 165 | }; 166 | }; 167 | }; 168 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; 169 | compatibilityVersion = "Xcode 9.3"; 170 | developmentRegion = en; 171 | hasScannedForEncodings = 0; 172 | knownRegions = ( 173 | en, 174 | Base, 175 | ); 176 | mainGroup = 97C146E51CF9000F007C117D; 177 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */; 178 | projectDirPath = ""; 179 | projectRoot = ""; 180 | targets = ( 181 | 97C146ED1CF9000F007C117D /* Runner */, 182 | ); 183 | }; 184 | /* End PBXProject section */ 185 | 186 | /* Begin PBXResourcesBuildPhase section */ 187 | 97C146EC1CF9000F007C117D /* Resources */ = { 188 | isa = PBXResourcesBuildPhase; 189 | buildActionMask = 2147483647; 190 | files = ( 191 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 192 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 193 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 194 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 195 | ); 196 | runOnlyForDeploymentPostprocessing = 0; 197 | }; 198 | /* End PBXResourcesBuildPhase section */ 199 | 200 | /* Begin PBXShellScriptBuildPhase section */ 201 | 17C1869A00BD25F27C547507 /* [CP] Embed Pods Frameworks */ = { 202 | isa = PBXShellScriptBuildPhase; 203 | buildActionMask = 2147483647; 204 | files = ( 205 | ); 206 | inputFileListPaths = ( 207 | "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", 208 | ); 209 | name = "[CP] Embed Pods Frameworks"; 210 | outputFileListPaths = ( 211 | "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", 212 | ); 213 | runOnlyForDeploymentPostprocessing = 0; 214 | shellPath = /bin/sh; 215 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; 216 | showEnvVarsInLog = 0; 217 | }; 218 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 219 | isa = PBXShellScriptBuildPhase; 220 | buildActionMask = 2147483647; 221 | files = ( 222 | ); 223 | inputPaths = ( 224 | ); 225 | name = "Thin Binary"; 226 | outputPaths = ( 227 | ); 228 | runOnlyForDeploymentPostprocessing = 0; 229 | shellPath = /bin/sh; 230 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; 231 | }; 232 | 9740EEB61CF901F6004384FC /* Run Script */ = { 233 | isa = PBXShellScriptBuildPhase; 234 | buildActionMask = 2147483647; 235 | files = ( 236 | ); 237 | inputPaths = ( 238 | ); 239 | name = "Run Script"; 240 | outputPaths = ( 241 | ); 242 | runOnlyForDeploymentPostprocessing = 0; 243 | shellPath = /bin/sh; 244 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 245 | }; 246 | BD757E512072C34CADA60790 /* [CP] Check Pods Manifest.lock */ = { 247 | isa = PBXShellScriptBuildPhase; 248 | buildActionMask = 2147483647; 249 | files = ( 250 | ); 251 | inputFileListPaths = ( 252 | ); 253 | inputPaths = ( 254 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 255 | "${PODS_ROOT}/Manifest.lock", 256 | ); 257 | name = "[CP] Check Pods Manifest.lock"; 258 | outputFileListPaths = ( 259 | ); 260 | outputPaths = ( 261 | "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", 262 | ); 263 | runOnlyForDeploymentPostprocessing = 0; 264 | shellPath = /bin/sh; 265 | 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"; 266 | showEnvVarsInLog = 0; 267 | }; 268 | /* End PBXShellScriptBuildPhase section */ 269 | 270 | /* Begin PBXSourcesBuildPhase section */ 271 | 97C146EA1CF9000F007C117D /* Sources */ = { 272 | isa = PBXSourcesBuildPhase; 273 | buildActionMask = 2147483647; 274 | files = ( 275 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, 276 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 277 | ); 278 | runOnlyForDeploymentPostprocessing = 0; 279 | }; 280 | /* End PBXSourcesBuildPhase section */ 281 | 282 | /* Begin PBXVariantGroup section */ 283 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = { 284 | isa = PBXVariantGroup; 285 | children = ( 286 | 97C146FB1CF9000F007C117D /* Base */, 287 | ); 288 | name = Main.storyboard; 289 | sourceTree = ""; 290 | }; 291 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { 292 | isa = PBXVariantGroup; 293 | children = ( 294 | 97C147001CF9000F007C117D /* Base */, 295 | ); 296 | name = LaunchScreen.storyboard; 297 | sourceTree = ""; 298 | }; 299 | /* End PBXVariantGroup section */ 300 | 301 | /* Begin XCBuildConfiguration section */ 302 | 249021D3217E4FDB00AE95B9 /* Profile */ = { 303 | isa = XCBuildConfiguration; 304 | buildSettings = { 305 | ALWAYS_SEARCH_USER_PATHS = NO; 306 | CLANG_ANALYZER_NONNULL = YES; 307 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 308 | CLANG_CXX_LIBRARY = "libc++"; 309 | CLANG_ENABLE_MODULES = YES; 310 | CLANG_ENABLE_OBJC_ARC = YES; 311 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 312 | CLANG_WARN_BOOL_CONVERSION = YES; 313 | CLANG_WARN_COMMA = YES; 314 | CLANG_WARN_CONSTANT_CONVERSION = YES; 315 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 316 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 317 | CLANG_WARN_EMPTY_BODY = YES; 318 | CLANG_WARN_ENUM_CONVERSION = YES; 319 | CLANG_WARN_INFINITE_RECURSION = YES; 320 | CLANG_WARN_INT_CONVERSION = YES; 321 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 322 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 323 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 324 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 325 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 326 | CLANG_WARN_STRICT_PROTOTYPES = YES; 327 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 328 | CLANG_WARN_UNREACHABLE_CODE = YES; 329 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 330 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 331 | COPY_PHASE_STRIP = NO; 332 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 333 | ENABLE_NS_ASSERTIONS = NO; 334 | ENABLE_STRICT_OBJC_MSGSEND = YES; 335 | GCC_C_LANGUAGE_STANDARD = gnu99; 336 | GCC_NO_COMMON_BLOCKS = YES; 337 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 338 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 339 | GCC_WARN_UNDECLARED_SELECTOR = YES; 340 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 341 | GCC_WARN_UNUSED_FUNCTION = YES; 342 | GCC_WARN_UNUSED_VARIABLE = YES; 343 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 344 | MTL_ENABLE_DEBUG_INFO = NO; 345 | SDKROOT = iphoneos; 346 | SUPPORTED_PLATFORMS = iphoneos; 347 | TARGETED_DEVICE_FAMILY = "1,2"; 348 | VALIDATE_PRODUCT = YES; 349 | }; 350 | name = Profile; 351 | }; 352 | 249021D4217E4FDB00AE95B9 /* Profile */ = { 353 | isa = XCBuildConfiguration; 354 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 355 | buildSettings = { 356 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 357 | CLANG_ENABLE_MODULES = YES; 358 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 359 | ENABLE_BITCODE = NO; 360 | INFOPLIST_FILE = Runner/Info.plist; 361 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 362 | PRODUCT_BUNDLE_IDENTIFIER = org.jezequel.example; 363 | PRODUCT_NAME = "$(TARGET_NAME)"; 364 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 365 | SWIFT_VERSION = 5.0; 366 | VERSIONING_SYSTEM = "apple-generic"; 367 | }; 368 | name = Profile; 369 | }; 370 | 97C147031CF9000F007C117D /* Debug */ = { 371 | isa = XCBuildConfiguration; 372 | buildSettings = { 373 | ALWAYS_SEARCH_USER_PATHS = NO; 374 | CLANG_ANALYZER_NONNULL = YES; 375 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 376 | CLANG_CXX_LIBRARY = "libc++"; 377 | CLANG_ENABLE_MODULES = YES; 378 | CLANG_ENABLE_OBJC_ARC = YES; 379 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 380 | CLANG_WARN_BOOL_CONVERSION = YES; 381 | CLANG_WARN_COMMA = YES; 382 | CLANG_WARN_CONSTANT_CONVERSION = YES; 383 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 384 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 385 | CLANG_WARN_EMPTY_BODY = YES; 386 | CLANG_WARN_ENUM_CONVERSION = YES; 387 | CLANG_WARN_INFINITE_RECURSION = YES; 388 | CLANG_WARN_INT_CONVERSION = YES; 389 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 390 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 391 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 392 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 393 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 394 | CLANG_WARN_STRICT_PROTOTYPES = YES; 395 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 396 | CLANG_WARN_UNREACHABLE_CODE = YES; 397 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 398 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 399 | COPY_PHASE_STRIP = NO; 400 | DEBUG_INFORMATION_FORMAT = dwarf; 401 | ENABLE_STRICT_OBJC_MSGSEND = YES; 402 | ENABLE_TESTABILITY = YES; 403 | GCC_C_LANGUAGE_STANDARD = gnu99; 404 | GCC_DYNAMIC_NO_PIC = NO; 405 | GCC_NO_COMMON_BLOCKS = YES; 406 | GCC_OPTIMIZATION_LEVEL = 0; 407 | GCC_PREPROCESSOR_DEFINITIONS = ( 408 | "DEBUG=1", 409 | "$(inherited)", 410 | ); 411 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 412 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 413 | GCC_WARN_UNDECLARED_SELECTOR = YES; 414 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 415 | GCC_WARN_UNUSED_FUNCTION = YES; 416 | GCC_WARN_UNUSED_VARIABLE = YES; 417 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 418 | MTL_ENABLE_DEBUG_INFO = YES; 419 | ONLY_ACTIVE_ARCH = YES; 420 | SDKROOT = iphoneos; 421 | TARGETED_DEVICE_FAMILY = "1,2"; 422 | }; 423 | name = Debug; 424 | }; 425 | 97C147041CF9000F007C117D /* Release */ = { 426 | isa = XCBuildConfiguration; 427 | buildSettings = { 428 | ALWAYS_SEARCH_USER_PATHS = NO; 429 | CLANG_ANALYZER_NONNULL = YES; 430 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 431 | CLANG_CXX_LIBRARY = "libc++"; 432 | CLANG_ENABLE_MODULES = YES; 433 | CLANG_ENABLE_OBJC_ARC = YES; 434 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 435 | CLANG_WARN_BOOL_CONVERSION = YES; 436 | CLANG_WARN_COMMA = YES; 437 | CLANG_WARN_CONSTANT_CONVERSION = YES; 438 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 439 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 440 | CLANG_WARN_EMPTY_BODY = YES; 441 | CLANG_WARN_ENUM_CONVERSION = YES; 442 | CLANG_WARN_INFINITE_RECURSION = YES; 443 | CLANG_WARN_INT_CONVERSION = YES; 444 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 445 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 446 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 447 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 448 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 449 | CLANG_WARN_STRICT_PROTOTYPES = YES; 450 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 451 | CLANG_WARN_UNREACHABLE_CODE = YES; 452 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 453 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 454 | COPY_PHASE_STRIP = NO; 455 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 456 | ENABLE_NS_ASSERTIONS = NO; 457 | ENABLE_STRICT_OBJC_MSGSEND = YES; 458 | GCC_C_LANGUAGE_STANDARD = gnu99; 459 | GCC_NO_COMMON_BLOCKS = YES; 460 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 461 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 462 | GCC_WARN_UNDECLARED_SELECTOR = YES; 463 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 464 | GCC_WARN_UNUSED_FUNCTION = YES; 465 | GCC_WARN_UNUSED_VARIABLE = YES; 466 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 467 | MTL_ENABLE_DEBUG_INFO = NO; 468 | SDKROOT = iphoneos; 469 | SUPPORTED_PLATFORMS = iphoneos; 470 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 471 | TARGETED_DEVICE_FAMILY = "1,2"; 472 | VALIDATE_PRODUCT = YES; 473 | }; 474 | name = Release; 475 | }; 476 | 97C147061CF9000F007C117D /* Debug */ = { 477 | isa = XCBuildConfiguration; 478 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 479 | buildSettings = { 480 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 481 | CLANG_ENABLE_MODULES = YES; 482 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 483 | ENABLE_BITCODE = NO; 484 | INFOPLIST_FILE = Runner/Info.plist; 485 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 486 | PRODUCT_BUNDLE_IDENTIFIER = org.jezequel.example; 487 | PRODUCT_NAME = "$(TARGET_NAME)"; 488 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 489 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 490 | SWIFT_VERSION = 5.0; 491 | VERSIONING_SYSTEM = "apple-generic"; 492 | }; 493 | name = Debug; 494 | }; 495 | 97C147071CF9000F007C117D /* Release */ = { 496 | isa = XCBuildConfiguration; 497 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 498 | buildSettings = { 499 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 500 | CLANG_ENABLE_MODULES = YES; 501 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 502 | ENABLE_BITCODE = NO; 503 | INFOPLIST_FILE = Runner/Info.plist; 504 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 505 | PRODUCT_BUNDLE_IDENTIFIER = org.jezequel.example; 506 | PRODUCT_NAME = "$(TARGET_NAME)"; 507 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 508 | SWIFT_VERSION = 5.0; 509 | VERSIONING_SYSTEM = "apple-generic"; 510 | }; 511 | name = Release; 512 | }; 513 | /* End XCBuildConfiguration section */ 514 | 515 | /* Begin XCConfigurationList section */ 516 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 517 | isa = XCConfigurationList; 518 | buildConfigurations = ( 519 | 97C147031CF9000F007C117D /* Debug */, 520 | 97C147041CF9000F007C117D /* Release */, 521 | 249021D3217E4FDB00AE95B9 /* Profile */, 522 | ); 523 | defaultConfigurationIsVisible = 0; 524 | defaultConfigurationName = Release; 525 | }; 526 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 527 | isa = XCConfigurationList; 528 | buildConfigurations = ( 529 | 97C147061CF9000F007C117D /* Debug */, 530 | 97C147071CF9000F007C117D /* Release */, 531 | 249021D4217E4FDB00AE95B9 /* Profile */, 532 | ); 533 | defaultConfigurationIsVisible = 0; 534 | defaultConfigurationName = Release; 535 | }; 536 | /* End XCConfigurationList section */ 537 | }; 538 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 539 | } 540 | -------------------------------------------------------------------------------- /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/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/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/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/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/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/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/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/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/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/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/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/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/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/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/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/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/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/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/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/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/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/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/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/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/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/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/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/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/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/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/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/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 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | example 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(FLUTTER_BUILD_NAME) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UIViewControllerBasedStatusBarAppearance 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:secure_application/secure_application.dart'; 5 | 6 | void main() => runApp(MaterialApp(home: MyApp())); 7 | 8 | class MyApp extends StatefulWidget { 9 | @override 10 | _MyAppState createState() => _MyAppState(); 11 | } 12 | 13 | class _MyAppState extends State { 14 | bool failedAuth = false; 15 | double blurr = 20; 16 | double opacity = 0.6; 17 | StreamSubscription? subLock; 18 | List history = []; 19 | 20 | @override 21 | void initState() { 22 | super.initState(); 23 | } 24 | 25 | @override 26 | void dispose() { 27 | subLock?.cancel(); 28 | super.dispose(); 29 | } 30 | 31 | @override 32 | Widget build(BuildContext context) { 33 | var width = MediaQuery.of(context).size.width * 0.8; 34 | return MaterialApp( 35 | home: SecureApplication( 36 | nativeRemoveDelay: 1000, 37 | onNeedUnlock: (secure) async { 38 | print( 39 | 'need unlock maybe use biometric to confirm and then sercure.unlock() or you can use the lockedBuilder'); 40 | // var authResult = authMyUser(); 41 | // if (authResul) { 42 | // secure.unlock(); 43 | // return SecureApplicationAuthenticationStatus.SUCCESS; 44 | //} 45 | // else { 46 | // return SecureApplicationAuthenticationStatus.FAILED; 47 | //} 48 | return null; 49 | }, 50 | onAuthenticationFailed: () async { 51 | // clean you data 52 | setState(() { 53 | failedAuth = true; 54 | }); 55 | print('auth failed'); 56 | }, 57 | onAuthenticationSucceed: () async { 58 | // clean you data 59 | 60 | setState(() { 61 | failedAuth = false; 62 | }); 63 | print('auth success'); 64 | }, 65 | child: Builder(builder: (context) { 66 | if (subLock == null) 67 | subLock = SecureApplicationProvider.of(context, listen: false) 68 | ?.lockEvents 69 | .listen((s) => history.add( 70 | '${DateTime.now().toIso8601String()} - ${s ? 'locked' : 'unlocked'}')); 71 | return SecureGate( 72 | blurr: blurr, 73 | opacity: opacity, 74 | lockedBuilder: (context, secureNotifier) => Center( 75 | child: Column( 76 | mainAxisAlignment: MainAxisAlignment.center, 77 | children: [ 78 | ElevatedButton( 79 | child: Text('UNLOCK'), 80 | onPressed: () => secureNotifier?.authSuccess(unlock: true), 81 | ), 82 | ElevatedButton( 83 | child: Text('FAIL AUTHENTICATION'), 84 | onPressed: () => secureNotifier?.authFailed(unlock: true), 85 | ), 86 | ], 87 | )), 88 | child: Scaffold( 89 | appBar: AppBar( 90 | title: const Text('Secure Window Example'), 91 | ), 92 | body: Center( 93 | child: Builder(builder: (context) { 94 | var valueNotifier = SecureApplicationProvider.of(context); 95 | if (valueNotifier == null) 96 | throw new Exception( 97 | 'Unable to find secure application context'); 98 | return ListView( 99 | children: [ 100 | Text('This is secure content'), 101 | ValueListenableBuilder( 102 | valueListenable: valueNotifier, 103 | builder: (context, state, _) => state.secured 104 | ? Column( 105 | children: [ 106 | ElevatedButton( 107 | onPressed: () => valueNotifier.open(), 108 | child: Text('Open app'), 109 | ), 110 | state.paused 111 | ? ElevatedButton( 112 | onPressed: () => 113 | valueNotifier.unpause(), 114 | child: Text('resume security'), 115 | ) 116 | : ElevatedButton( 117 | onPressed: () => 118 | valueNotifier.pause(), 119 | child: Text('pause security'), 120 | ), 121 | ], 122 | ) 123 | : ElevatedButton( 124 | onPressed: () => valueNotifier.secure(), 125 | child: Text('Secure app'), 126 | ), 127 | ), 128 | failedAuth 129 | ? Text( 130 | 'Auth failed we cleaned sensitive data', 131 | style: TextStyle(color: Colors.red), 132 | ) 133 | : Text( 134 | 'Auth success', 135 | style: TextStyle(color: Colors.green), 136 | ), 137 | FlutterLogo( 138 | size: width, 139 | ), 140 | StreamBuilder( 141 | stream: valueNotifier.authenticationEvents, 142 | builder: (context, snapshot) => 143 | Text('Last auth status is: ${snapshot.data}'), 144 | ), 145 | ElevatedButton( 146 | onPressed: () => valueNotifier.lock(), 147 | child: Text('manually lock'), 148 | ), 149 | Padding( 150 | padding: const EdgeInsets.all(8.0), 151 | child: Row( 152 | children: [ 153 | Text('Blurr:'), 154 | Expanded( 155 | child: Slider( 156 | value: blurr, 157 | min: 0, 158 | max: 100, 159 | onChanged: (v) => setState(() => blurr = v)), 160 | ), 161 | Text(blurr.floor().toString()), 162 | ], 163 | ), 164 | ), 165 | Padding( 166 | padding: const EdgeInsets.all(8.0), 167 | child: Row( 168 | children: [ 169 | Text('opacity:'), 170 | Expanded( 171 | child: Slider( 172 | value: opacity, 173 | min: 0, 174 | max: 1, 175 | onChanged: (v) => 176 | setState(() => opacity = v)), 177 | ), 178 | Text((opacity * 100).floor().toString() + "%"), 179 | ], 180 | ), 181 | ), 182 | ...history.map((h) => Text(h)).toList(), 183 | ], 184 | ); 185 | }), 186 | ), 187 | ), 188 | ); 189 | }), 190 | ), 191 | ); 192 | } 193 | } 194 | -------------------------------------------------------------------------------- /example/pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63 9 | url: "https://pub.dev" 10 | source: hosted 11 | version: "2.12.0" 12 | boolean_selector: 13 | dependency: transitive 14 | description: 15 | name: boolean_selector 16 | sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" 17 | url: "https://pub.dev" 18 | source: hosted 19 | version: "2.1.2" 20 | characters: 21 | dependency: transitive 22 | description: 23 | name: characters 24 | sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 25 | url: "https://pub.dev" 26 | source: hosted 27 | version: "1.4.0" 28 | clock: 29 | dependency: transitive 30 | description: 31 | name: clock 32 | sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b 33 | url: "https://pub.dev" 34 | source: hosted 35 | version: "1.1.2" 36 | collection: 37 | dependency: transitive 38 | description: 39 | name: collection 40 | sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" 41 | url: "https://pub.dev" 42 | source: hosted 43 | version: "1.19.1" 44 | cupertino_icons: 45 | dependency: "direct main" 46 | description: 47 | name: cupertino_icons 48 | sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 49 | url: "https://pub.dev" 50 | source: hosted 51 | version: "1.0.8" 52 | fake_async: 53 | dependency: transitive 54 | description: 55 | name: fake_async 56 | sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc" 57 | url: "https://pub.dev" 58 | source: hosted 59 | version: "1.3.2" 60 | flutter: 61 | dependency: "direct main" 62 | description: flutter 63 | source: sdk 64 | version: "0.0.0" 65 | flutter_plugin_android_lifecycle: 66 | dependency: transitive 67 | description: 68 | name: flutter_plugin_android_lifecycle 69 | sha256: "5a1e6fb2c0561958d7e4c33574674bda7b77caaca7a33b758876956f2902eea3" 70 | url: "https://pub.dev" 71 | source: hosted 72 | version: "2.0.27" 73 | flutter_test: 74 | dependency: "direct dev" 75 | description: flutter 76 | source: sdk 77 | version: "0.0.0" 78 | flutter_web_plugins: 79 | dependency: transitive 80 | description: flutter 81 | source: sdk 82 | version: "0.0.0" 83 | leak_tracker: 84 | dependency: transitive 85 | description: 86 | name: leak_tracker 87 | sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec 88 | url: "https://pub.dev" 89 | source: hosted 90 | version: "10.0.8" 91 | leak_tracker_flutter_testing: 92 | dependency: transitive 93 | description: 94 | name: leak_tracker_flutter_testing 95 | sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573 96 | url: "https://pub.dev" 97 | source: hosted 98 | version: "3.0.9" 99 | leak_tracker_testing: 100 | dependency: transitive 101 | description: 102 | name: leak_tracker_testing 103 | sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" 104 | url: "https://pub.dev" 105 | source: hosted 106 | version: "3.0.1" 107 | matcher: 108 | dependency: transitive 109 | description: 110 | name: matcher 111 | sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 112 | url: "https://pub.dev" 113 | source: hosted 114 | version: "0.12.17" 115 | material_color_utilities: 116 | dependency: transitive 117 | description: 118 | name: material_color_utilities 119 | sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec 120 | url: "https://pub.dev" 121 | source: hosted 122 | version: "0.11.1" 123 | meta: 124 | dependency: transitive 125 | description: 126 | name: meta 127 | sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c 128 | url: "https://pub.dev" 129 | source: hosted 130 | version: "1.16.0" 131 | path: 132 | dependency: transitive 133 | description: 134 | name: path 135 | sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" 136 | url: "https://pub.dev" 137 | source: hosted 138 | version: "1.9.1" 139 | rxdart: 140 | dependency: transitive 141 | description: 142 | name: rxdart 143 | sha256: "5c3004a4a8dbb94bd4bf5412a4def4acdaa12e12f269737a5751369e12d1a962" 144 | url: "https://pub.dev" 145 | source: hosted 146 | version: "0.28.0" 147 | secure_application: 148 | dependency: "direct main" 149 | description: 150 | path: ".." 151 | relative: true 152 | source: path 153 | version: "4.0.1" 154 | sky_engine: 155 | dependency: transitive 156 | description: flutter 157 | source: sdk 158 | version: "0.0.0" 159 | source_span: 160 | dependency: transitive 161 | description: 162 | name: source_span 163 | sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c" 164 | url: "https://pub.dev" 165 | source: hosted 166 | version: "1.10.1" 167 | stack_trace: 168 | dependency: transitive 169 | description: 170 | name: stack_trace 171 | sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" 172 | url: "https://pub.dev" 173 | source: hosted 174 | version: "1.12.1" 175 | stream_channel: 176 | dependency: transitive 177 | description: 178 | name: stream_channel 179 | sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" 180 | url: "https://pub.dev" 181 | source: hosted 182 | version: "2.1.4" 183 | string_scanner: 184 | dependency: transitive 185 | description: 186 | name: string_scanner 187 | sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" 188 | url: "https://pub.dev" 189 | source: hosted 190 | version: "1.4.1" 191 | term_glyph: 192 | dependency: transitive 193 | description: 194 | name: term_glyph 195 | sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" 196 | url: "https://pub.dev" 197 | source: hosted 198 | version: "1.2.2" 199 | test_api: 200 | dependency: transitive 201 | description: 202 | name: test_api 203 | sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd 204 | url: "https://pub.dev" 205 | source: hosted 206 | version: "0.7.4" 207 | vector_math: 208 | dependency: transitive 209 | description: 210 | name: vector_math 211 | sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" 212 | url: "https://pub.dev" 213 | source: hosted 214 | version: "2.1.4" 215 | vm_service: 216 | dependency: transitive 217 | description: 218 | name: vm_service 219 | sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14" 220 | url: "https://pub.dev" 221 | source: hosted 222 | version: "14.3.1" 223 | sdks: 224 | dart: ">=3.7.0-0 <4.0.0" 225 | flutter: ">=3.27.0" 226 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: sa_example 2 | description: Demonstrates how to use the secure_application plugin. 3 | publish_to: 'none' 4 | 5 | environment: 6 | sdk: ">=2.12.0 <4.0.0" 7 | 8 | dependencies: 9 | flutter: 10 | sdk: flutter 11 | 12 | # The following adds the Cupertino Icons font to your application. 13 | # Use with the CupertinoIcons class for iOS style icons. 14 | cupertino_icons: ^1.0.6 15 | 16 | secure_application: 17 | path: ../ 18 | dev_dependencies: 19 | flutter_test: 20 | sdk: flutter 21 | 22 | flutter: 23 | 24 | # The following line ensures that the Material Icons font is 25 | # included with your application, so that you can use the icons in 26 | # the material Icons class. 27 | uses-material-design: true 28 | 29 | # To add assets to your application, add an assets section, like this: 30 | # assets: 31 | # - images/a_dot_burr.jpeg 32 | # - images/a_dot_ham.jpeg 33 | 34 | # An image asset can refer to one or more resolution-specific "variants", see 35 | # https://flutter.dev/assets-and-images/#resolution-aware. 36 | 37 | # For details regarding adding assets from package dependencies, see 38 | # https://flutter.dev/assets-and-images/#from-packages 39 | 40 | # To add custom fonts to your application, add a fonts section here, 41 | # in this "flutter" section. Each entry in this list should have a 42 | # "family" key with the font family name, and a "fonts" key with a 43 | # list giving the asset and other descriptors for the font. For 44 | # example: 45 | # fonts: 46 | # - family: Schyler 47 | # fonts: 48 | # - asset: fonts/Schyler-Regular.ttf 49 | # - asset: fonts/Schyler-Italic.ttf 50 | # style: italic 51 | # - family: Trajan Pro 52 | # fonts: 53 | # - asset: fonts/TrajanPro.ttf 54 | # - asset: fonts/TrajanPro_Bold.ttf 55 | # weight: 700 56 | # 57 | # For details regarding fonts from package dependencies, 58 | # see https://flutter.dev/custom-fonts/#from-packages 59 | -------------------------------------------------------------------------------- /example/screenshot/gate_off.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/example/screenshot/gate_off.jpg -------------------------------------------------------------------------------- /example/screenshot/gate_on.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/example/screenshot/gate_on.jpg -------------------------------------------------------------------------------- /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 | 9 | 10 | void main() {} 11 | -------------------------------------------------------------------------------- /example/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/example/web/favicon.png -------------------------------------------------------------------------------- /example/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/example/web/icons/Icon-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/example/web/icons/Icon-512.png -------------------------------------------------------------------------------- /example/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | secure_application_example 30 | 31 | 32 | 33 | 36 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /example/web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "secure_application_example", 3 | "short_name": "secure_application_example", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "Demonstrates how to use the secure_application plugin.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /example/windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /example/windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15) 2 | project(secure_application_example LANGUAGES CXX) 3 | 4 | set(BINARY_NAME "secure_application_example") 5 | 6 | cmake_policy(SET CMP0063 NEW) 7 | 8 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 9 | 10 | # Configure build options. 11 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 12 | if(IS_MULTICONFIG) 13 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 14 | CACHE STRING "" FORCE) 15 | else() 16 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 17 | set(CMAKE_BUILD_TYPE "Debug" CACHE 18 | STRING "Flutter build mode" FORCE) 19 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 20 | "Debug" "Profile" "Release") 21 | endif() 22 | endif() 23 | 24 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 25 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 26 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 27 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 28 | 29 | # Use Unicode for all projects. 30 | add_definitions(-DUNICODE -D_UNICODE) 31 | 32 | # Compilation settings that should be applied to most targets. 33 | function(APPLY_STANDARD_SETTINGS TARGET) 34 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 35 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 36 | target_compile_options(${TARGET} PRIVATE /EHsc) 37 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 38 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 39 | endfunction() 40 | 41 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 42 | 43 | # Flutter library and tool build rules. 44 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 45 | 46 | # Application build 47 | add_subdirectory("runner") 48 | 49 | # Generated plugin build rules, which manage building the plugins and adding 50 | # them to the application. 51 | include(flutter/generated_plugins.cmake) 52 | 53 | 54 | # === Installation === 55 | # Support files are copied into place next to the executable, so that it can 56 | # run in place. This is done instead of making a separate bundle (as on Linux) 57 | # so that building and running from within Visual Studio will work. 58 | set(BUILD_BUNDLE_DIR "$") 59 | # Make the "install" step default, as it's required to run. 60 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 61 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 62 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 63 | endif() 64 | 65 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 66 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 67 | 68 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 69 | COMPONENT Runtime) 70 | 71 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 72 | COMPONENT Runtime) 73 | 74 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 75 | COMPONENT Runtime) 76 | 77 | if(PLUGIN_BUNDLED_LIBRARIES) 78 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 79 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 80 | COMPONENT Runtime) 81 | endif() 82 | 83 | # Fully re-copy the assets directory on each build to avoid having stale files 84 | # from a previous install. 85 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 86 | install(CODE " 87 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 88 | " COMPONENT Runtime) 89 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 90 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 91 | 92 | # Install the AOT library on non-Debug builds only. 93 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 94 | CONFIGURATIONS Profile;Release 95 | COMPONENT Runtime) 96 | -------------------------------------------------------------------------------- /example/windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15) 2 | 3 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 4 | 5 | # Configuration provided via flutter tool. 6 | include(${EPHEMERAL_DIR}/generated_config.cmake) 7 | 8 | # TODO: Move the rest of this into files in ephemeral. See 9 | # https://github.com/flutter/flutter/issues/57146. 10 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 11 | 12 | # Set fallback configurations for older versions of the flutter tool. 13 | if (NOT DEFINED FLUTTER_TARGET_PLATFORM) 14 | set(FLUTTER_TARGET_PLATFORM "windows-x64") 15 | endif() 16 | 17 | # === Flutter Library === 18 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 19 | 20 | # Published to parent scope for install step. 21 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 22 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 23 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 24 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 25 | 26 | list(APPEND FLUTTER_LIBRARY_HEADERS 27 | "flutter_export.h" 28 | "flutter_windows.h" 29 | "flutter_messenger.h" 30 | "flutter_plugin_registrar.h" 31 | "flutter_texture_registrar.h" 32 | ) 33 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 34 | add_library(flutter INTERFACE) 35 | target_include_directories(flutter INTERFACE 36 | "${EPHEMERAL_DIR}" 37 | ) 38 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 39 | add_dependencies(flutter flutter_assemble) 40 | 41 | # === Wrapper === 42 | list(APPEND CPP_WRAPPER_SOURCES_CORE 43 | "core_implementations.cc" 44 | "standard_codec.cc" 45 | ) 46 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 47 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 48 | "plugin_registrar.cc" 49 | ) 50 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 51 | list(APPEND CPP_WRAPPER_SOURCES_APP 52 | "flutter_engine.cc" 53 | "flutter_view_controller.cc" 54 | ) 55 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 56 | 57 | # Wrapper sources needed for a plugin. 58 | add_library(flutter_wrapper_plugin STATIC 59 | ${CPP_WRAPPER_SOURCES_CORE} 60 | ${CPP_WRAPPER_SOURCES_PLUGIN} 61 | ) 62 | apply_standard_settings(flutter_wrapper_plugin) 63 | set_target_properties(flutter_wrapper_plugin PROPERTIES 64 | POSITION_INDEPENDENT_CODE ON) 65 | set_target_properties(flutter_wrapper_plugin PROPERTIES 66 | CXX_VISIBILITY_PRESET hidden) 67 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 68 | target_include_directories(flutter_wrapper_plugin PUBLIC 69 | "${WRAPPER_ROOT}/include" 70 | ) 71 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 72 | 73 | # Wrapper sources needed for the runner. 74 | add_library(flutter_wrapper_app STATIC 75 | ${CPP_WRAPPER_SOURCES_CORE} 76 | ${CPP_WRAPPER_SOURCES_APP} 77 | ) 78 | apply_standard_settings(flutter_wrapper_app) 79 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 80 | target_include_directories(flutter_wrapper_app PUBLIC 81 | "${WRAPPER_ROOT}/include" 82 | ) 83 | add_dependencies(flutter_wrapper_app flutter_assemble) 84 | 85 | # === Flutter tool backend === 86 | # _phony_ is a non-existent file to force this command to run every time, 87 | # since currently there's no way to get a full input/output list from the 88 | # flutter tool. 89 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 90 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 91 | add_custom_command( 92 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 93 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 94 | ${CPP_WRAPPER_SOURCES_APP} 95 | ${PHONY_OUTPUT} 96 | COMMAND ${CMAKE_COMMAND} -E env 97 | ${FLUTTER_TOOL_ENVIRONMENT} 98 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 99 | ${FLUTTER_TARGET_PLATFORM} $ 100 | VERBATIM 101 | ) 102 | add_custom_target(flutter_assemble DEPENDS 103 | "${FLUTTER_LIBRARY}" 104 | ${FLUTTER_LIBRARY_HEADERS} 105 | ${CPP_WRAPPER_SOURCES_CORE} 106 | ${CPP_WRAPPER_SOURCES_PLUGIN} 107 | ${CPP_WRAPPER_SOURCES_APP} 108 | ) 109 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | 11 | void RegisterPlugins(flutter::PluginRegistry* registry) { 12 | SecureApplicationPluginRegisterWithRegistrar( 13 | registry->GetRegistrarForPlugin("SecureApplicationPlugin")); 14 | } 15 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | secure_application 7 | ) 8 | 9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 10 | ) 11 | 12 | set(PLUGIN_BUNDLED_LIBRARIES) 13 | 14 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 19 | endforeach(plugin) 20 | 21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 24 | endforeach(ffi_plugin) 25 | -------------------------------------------------------------------------------- /example/windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15) 2 | project(runner LANGUAGES CXX) 3 | 4 | add_executable(${BINARY_NAME} WIN32 5 | "flutter_window.cpp" 6 | "main.cpp" 7 | "run_loop.cpp" 8 | "utils.cpp" 9 | "win32_window.cpp" 10 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 11 | "Runner.rc" 12 | "runner.exe.manifest" 13 | ) 14 | apply_standard_settings(${BINARY_NAME}) 15 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 16 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 17 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 18 | add_dependencies(${BINARY_NAME} flutter_assemble) 19 | -------------------------------------------------------------------------------- /example/windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) 64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0,0 67 | #endif 68 | 69 | #if defined(FLUTTER_VERSION) 70 | #define VERSION_AS_STRING FLUTTER_VERSION 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "org.jezequel" "\0" 93 | VALUE "FileDescription", "Demonstrates how to use the secure_application plugin." "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "secure_application_example" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2021 org.jezequel. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "secure_application_example.exe" "\0" 98 | VALUE "ProductName", "secure_application_example" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /example/windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(RunLoop* run_loop, 8 | const flutter::DartProject& project) 9 | : run_loop_(run_loop), project_(project) {} 10 | 11 | FlutterWindow::~FlutterWindow() {} 12 | 13 | bool FlutterWindow::OnCreate() { 14 | if (!Win32Window::OnCreate()) { 15 | return false; 16 | } 17 | 18 | RECT frame = GetClientArea(); 19 | 20 | // The size here must match the window dimensions to avoid unnecessary surface 21 | // creation / destruction in the startup path. 22 | flutter_controller_ = std::make_unique( 23 | frame.right - frame.left, frame.bottom - frame.top, project_); 24 | // Ensure that basic setup of the controller was successful. 25 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 26 | return false; 27 | } 28 | RegisterPlugins(flutter_controller_->engine()); 29 | run_loop_->RegisterFlutterInstance(flutter_controller_->engine()); 30 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 31 | return true; 32 | } 33 | 34 | void FlutterWindow::OnDestroy() { 35 | if (flutter_controller_) { 36 | run_loop_->UnregisterFlutterInstance(flutter_controller_->engine()); 37 | flutter_controller_ = nullptr; 38 | } 39 | 40 | Win32Window::OnDestroy(); 41 | } 42 | 43 | LRESULT 44 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 45 | WPARAM const wparam, 46 | LPARAM const lparam) noexcept { 47 | // Give Flutter, including plugins, an opporutunity to handle window messages. 48 | if (flutter_controller_) { 49 | std::optional result = 50 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 51 | lparam); 52 | if (result) { 53 | return *result; 54 | } 55 | } 56 | 57 | switch (message) { 58 | case WM_FONTCHANGE: 59 | flutter_controller_->engine()->ReloadSystemFonts(); 60 | break; 61 | } 62 | 63 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 64 | } 65 | -------------------------------------------------------------------------------- /example/windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "run_loop.h" 10 | #include "win32_window.h" 11 | 12 | // A window that does nothing but host a Flutter view. 13 | class FlutterWindow : public Win32Window { 14 | public: 15 | // Creates a new FlutterWindow driven by the |run_loop|, hosting a 16 | // Flutter view running |project|. 17 | explicit FlutterWindow(RunLoop* run_loop, 18 | const flutter::DartProject& project); 19 | virtual ~FlutterWindow(); 20 | 21 | protected: 22 | // Win32Window: 23 | bool OnCreate() override; 24 | void OnDestroy() override; 25 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 26 | LPARAM const lparam) noexcept override; 27 | 28 | private: 29 | // The run loop driving events for this window. 30 | RunLoop* run_loop_; 31 | 32 | // The project to run. 33 | flutter::DartProject project_; 34 | 35 | // The Flutter instance hosted by this window. 36 | std::unique_ptr flutter_controller_; 37 | }; 38 | 39 | #endif // RUNNER_FLUTTER_WINDOW_H_ 40 | -------------------------------------------------------------------------------- /example/windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "run_loop.h" 7 | #include "utils.h" 8 | 9 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 10 | _In_ wchar_t *command_line, _In_ int show_command) { 11 | // Attach to console when present (e.g., 'flutter run') or create a 12 | // new console when running with a debugger. 13 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 14 | CreateAndAttachConsole(); 15 | } 16 | 17 | // Initialize COM, so that it is available for use in the library and/or 18 | // plugins. 19 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 20 | 21 | RunLoop run_loop; 22 | 23 | flutter::DartProject project(L"data"); 24 | 25 | std::vector command_line_arguments = 26 | GetCommandLineArguments(); 27 | 28 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 29 | 30 | FlutterWindow window(&run_loop, project); 31 | Win32Window::Point origin(10, 10); 32 | Win32Window::Size size(1280, 720); 33 | if (!window.CreateAndShow(L"secure_application_example", origin, size)) { 34 | return EXIT_FAILURE; 35 | } 36 | window.SetQuitOnClose(true); 37 | 38 | run_loop.Run(); 39 | 40 | ::CoUninitialize(); 41 | return EXIT_SUCCESS; 42 | } 43 | -------------------------------------------------------------------------------- /example/windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /example/windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/example/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /example/windows/runner/run_loop.cpp: -------------------------------------------------------------------------------- 1 | #include "run_loop.h" 2 | 3 | #include 4 | 5 | #include 6 | 7 | RunLoop::RunLoop() {} 8 | 9 | RunLoop::~RunLoop() {} 10 | 11 | void RunLoop::Run() { 12 | bool keep_running = true; 13 | TimePoint next_flutter_event_time = TimePoint::clock::now(); 14 | while (keep_running) { 15 | std::chrono::nanoseconds wait_duration = 16 | std::max(std::chrono::nanoseconds(0), 17 | next_flutter_event_time - TimePoint::clock::now()); 18 | ::MsgWaitForMultipleObjects( 19 | 0, nullptr, FALSE, static_cast(wait_duration.count() / 1000), 20 | QS_ALLINPUT); 21 | bool processed_events = false; 22 | MSG message; 23 | // All pending Windows messages must be processed; MsgWaitForMultipleObjects 24 | // won't return again for items left in the queue after PeekMessage. 25 | while (::PeekMessage(&message, nullptr, 0, 0, PM_REMOVE)) { 26 | processed_events = true; 27 | if (message.message == WM_QUIT) { 28 | keep_running = false; 29 | break; 30 | } 31 | ::TranslateMessage(&message); 32 | ::DispatchMessage(&message); 33 | // Allow Flutter to process messages each time a Windows message is 34 | // processed, to prevent starvation. 35 | next_flutter_event_time = 36 | std::min(next_flutter_event_time, ProcessFlutterMessages()); 37 | } 38 | // If the PeekMessage loop didn't run, process Flutter messages. 39 | if (!processed_events) { 40 | next_flutter_event_time = 41 | std::min(next_flutter_event_time, ProcessFlutterMessages()); 42 | } 43 | } 44 | } 45 | 46 | void RunLoop::RegisterFlutterInstance( 47 | flutter::FlutterEngine* flutter_instance) { 48 | flutter_instances_.insert(flutter_instance); 49 | } 50 | 51 | void RunLoop::UnregisterFlutterInstance( 52 | flutter::FlutterEngine* flutter_instance) { 53 | flutter_instances_.erase(flutter_instance); 54 | } 55 | 56 | RunLoop::TimePoint RunLoop::ProcessFlutterMessages() { 57 | TimePoint next_event_time = TimePoint::max(); 58 | for (auto instance : flutter_instances_) { 59 | std::chrono::nanoseconds wait_duration = instance->ProcessMessages(); 60 | if (wait_duration != std::chrono::nanoseconds::max()) { 61 | next_event_time = 62 | std::min(next_event_time, TimePoint::clock::now() + wait_duration); 63 | } 64 | } 65 | return next_event_time; 66 | } 67 | -------------------------------------------------------------------------------- /example/windows/runner/run_loop.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_RUN_LOOP_H_ 2 | #define RUNNER_RUN_LOOP_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | // A runloop that will service events for Flutter instances as well 10 | // as native messages. 11 | class RunLoop { 12 | public: 13 | RunLoop(); 14 | ~RunLoop(); 15 | 16 | // Prevent copying 17 | RunLoop(RunLoop const&) = delete; 18 | RunLoop& operator=(RunLoop const&) = delete; 19 | 20 | // Runs the run loop until the application quits. 21 | void Run(); 22 | 23 | // Registers the given Flutter instance for event servicing. 24 | void RegisterFlutterInstance( 25 | flutter::FlutterEngine* flutter_instance); 26 | 27 | // Unregisters the given Flutter instance from event servicing. 28 | void UnregisterFlutterInstance( 29 | flutter::FlutterEngine* flutter_instance); 30 | 31 | private: 32 | using TimePoint = std::chrono::steady_clock::time_point; 33 | 34 | // Processes all currently pending messages for registered Flutter instances. 35 | TimePoint ProcessFlutterMessages(); 36 | 37 | std::set flutter_instances_; 38 | }; 39 | 40 | #endif // RUNNER_RUN_LOOP_H_ 41 | -------------------------------------------------------------------------------- /example/windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /example/windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr); 51 | if (target_length == 0) { 52 | return std::string(); 53 | } 54 | std::string utf8_string; 55 | utf8_string.resize(target_length); 56 | int converted_length = ::WideCharToMultiByte( 57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 58 | -1, utf8_string.data(), 59 | target_length, nullptr, nullptr); 60 | if (converted_length == 0) { 61 | return std::string(); 62 | } 63 | return utf8_string; 64 | } 65 | -------------------------------------------------------------------------------- /example/windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /example/windows/runner/win32_window.cpp: -------------------------------------------------------------------------------- 1 | #include "win32_window.h" 2 | 3 | #include 4 | 5 | #include "resource.h" 6 | 7 | namespace { 8 | 9 | constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; 10 | 11 | // The number of Win32Window objects that currently exist. 12 | static int g_active_window_count = 0; 13 | 14 | using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); 15 | 16 | // Scale helper to convert logical scaler values to physical using passed in 17 | // scale factor 18 | int Scale(int source, double scale_factor) { 19 | return static_cast(source * scale_factor); 20 | } 21 | 22 | // Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. 23 | // This API is only needed for PerMonitor V1 awareness mode. 24 | void EnableFullDpiSupportIfAvailable(HWND hwnd) { 25 | HMODULE user32_module = LoadLibraryA("User32.dll"); 26 | if (!user32_module) { 27 | return; 28 | } 29 | auto enable_non_client_dpi_scaling = 30 | reinterpret_cast( 31 | GetProcAddress(user32_module, "EnableNonClientDpiScaling")); 32 | if (enable_non_client_dpi_scaling != nullptr) { 33 | enable_non_client_dpi_scaling(hwnd); 34 | FreeLibrary(user32_module); 35 | } 36 | } 37 | 38 | } // namespace 39 | 40 | // Manages the Win32Window's window class registration. 41 | class WindowClassRegistrar { 42 | public: 43 | ~WindowClassRegistrar() = default; 44 | 45 | // Returns the singleton registar instance. 46 | static WindowClassRegistrar* GetInstance() { 47 | if (!instance_) { 48 | instance_ = new WindowClassRegistrar(); 49 | } 50 | return instance_; 51 | } 52 | 53 | // Returns the name of the window class, registering the class if it hasn't 54 | // previously been registered. 55 | const wchar_t* GetWindowClass(); 56 | 57 | // Unregisters the window class. Should only be called if there are no 58 | // instances of the window. 59 | void UnregisterWindowClass(); 60 | 61 | private: 62 | WindowClassRegistrar() = default; 63 | 64 | static WindowClassRegistrar* instance_; 65 | 66 | bool class_registered_ = false; 67 | }; 68 | 69 | WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; 70 | 71 | const wchar_t* WindowClassRegistrar::GetWindowClass() { 72 | if (!class_registered_) { 73 | WNDCLASS window_class{}; 74 | window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); 75 | window_class.lpszClassName = kWindowClassName; 76 | window_class.style = CS_HREDRAW | CS_VREDRAW; 77 | window_class.cbClsExtra = 0; 78 | window_class.cbWndExtra = 0; 79 | window_class.hInstance = GetModuleHandle(nullptr); 80 | window_class.hIcon = 81 | LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); 82 | window_class.hbrBackground = 0; 83 | window_class.lpszMenuName = nullptr; 84 | window_class.lpfnWndProc = Win32Window::WndProc; 85 | RegisterClass(&window_class); 86 | class_registered_ = true; 87 | } 88 | return kWindowClassName; 89 | } 90 | 91 | void WindowClassRegistrar::UnregisterWindowClass() { 92 | UnregisterClass(kWindowClassName, nullptr); 93 | class_registered_ = false; 94 | } 95 | 96 | Win32Window::Win32Window() { 97 | ++g_active_window_count; 98 | } 99 | 100 | Win32Window::~Win32Window() { 101 | --g_active_window_count; 102 | Destroy(); 103 | } 104 | 105 | bool Win32Window::CreateAndShow(const std::wstring& title, 106 | const Point& origin, 107 | const Size& size) { 108 | Destroy(); 109 | 110 | const wchar_t* window_class = 111 | WindowClassRegistrar::GetInstance()->GetWindowClass(); 112 | 113 | const POINT target_point = {static_cast(origin.x), 114 | static_cast(origin.y)}; 115 | HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); 116 | UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); 117 | double scale_factor = dpi / 96.0; 118 | 119 | HWND window = CreateWindow( 120 | window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE, 121 | Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), 122 | Scale(size.width, scale_factor), Scale(size.height, scale_factor), 123 | nullptr, nullptr, GetModuleHandle(nullptr), this); 124 | 125 | if (!window) { 126 | return false; 127 | } 128 | 129 | return OnCreate(); 130 | } 131 | 132 | // static 133 | LRESULT CALLBACK Win32Window::WndProc(HWND const window, 134 | UINT const message, 135 | WPARAM const wparam, 136 | LPARAM const lparam) noexcept { 137 | if (message == WM_NCCREATE) { 138 | auto window_struct = reinterpret_cast(lparam); 139 | SetWindowLongPtr(window, GWLP_USERDATA, 140 | reinterpret_cast(window_struct->lpCreateParams)); 141 | 142 | auto that = static_cast(window_struct->lpCreateParams); 143 | EnableFullDpiSupportIfAvailable(window); 144 | that->window_handle_ = window; 145 | } else if (Win32Window* that = GetThisFromHandle(window)) { 146 | return that->MessageHandler(window, message, wparam, lparam); 147 | } 148 | 149 | return DefWindowProc(window, message, wparam, lparam); 150 | } 151 | 152 | LRESULT 153 | Win32Window::MessageHandler(HWND hwnd, 154 | UINT const message, 155 | WPARAM const wparam, 156 | LPARAM const lparam) noexcept { 157 | switch (message) { 158 | case WM_DESTROY: 159 | window_handle_ = nullptr; 160 | Destroy(); 161 | if (quit_on_close_) { 162 | PostQuitMessage(0); 163 | } 164 | return 0; 165 | 166 | case WM_DPICHANGED: { 167 | auto newRectSize = reinterpret_cast(lparam); 168 | LONG newWidth = newRectSize->right - newRectSize->left; 169 | LONG newHeight = newRectSize->bottom - newRectSize->top; 170 | 171 | SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, 172 | newHeight, SWP_NOZORDER | SWP_NOACTIVATE); 173 | 174 | return 0; 175 | } 176 | case WM_SIZE: { 177 | RECT rect = GetClientArea(); 178 | if (child_content_ != nullptr) { 179 | // Size and position the child window. 180 | MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, 181 | rect.bottom - rect.top, TRUE); 182 | } 183 | return 0; 184 | } 185 | 186 | case WM_ACTIVATE: 187 | if (child_content_ != nullptr) { 188 | SetFocus(child_content_); 189 | } 190 | return 0; 191 | } 192 | 193 | return DefWindowProc(window_handle_, message, wparam, lparam); 194 | } 195 | 196 | void Win32Window::Destroy() { 197 | OnDestroy(); 198 | 199 | if (window_handle_) { 200 | DestroyWindow(window_handle_); 201 | window_handle_ = nullptr; 202 | } 203 | if (g_active_window_count == 0) { 204 | WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); 205 | } 206 | } 207 | 208 | Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { 209 | return reinterpret_cast( 210 | GetWindowLongPtr(window, GWLP_USERDATA)); 211 | } 212 | 213 | void Win32Window::SetChildContent(HWND content) { 214 | child_content_ = content; 215 | SetParent(content, window_handle_); 216 | RECT frame = GetClientArea(); 217 | 218 | MoveWindow(content, frame.left, frame.top, frame.right - frame.left, 219 | frame.bottom - frame.top, true); 220 | 221 | SetFocus(child_content_); 222 | } 223 | 224 | RECT Win32Window::GetClientArea() { 225 | RECT frame; 226 | GetClientRect(window_handle_, &frame); 227 | return frame; 228 | } 229 | 230 | HWND Win32Window::GetHandle() { 231 | return window_handle_; 232 | } 233 | 234 | void Win32Window::SetQuitOnClose(bool quit_on_close) { 235 | quit_on_close_ = quit_on_close; 236 | } 237 | 238 | bool Win32Window::OnCreate() { 239 | // No-op; provided for subclasses. 240 | return true; 241 | } 242 | 243 | void Win32Window::OnDestroy() { 244 | // No-op; provided for subclasses. 245 | } 246 | -------------------------------------------------------------------------------- /example/windows/runner/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates and shows a win32 window with |title| and position and size using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size to will treat the width height passed in to this function 35 | // as logical pixels and scale to appropriate for the default monitor. Returns 36 | // true if the window was created successfully. 37 | bool CreateAndShow(const std::wstring& title, 38 | const Point& origin, 39 | const Size& size); 40 | 41 | // Release OS resources associated with window. 42 | void Destroy(); 43 | 44 | // Inserts |content| into the window tree. 45 | void SetChildContent(HWND content); 46 | 47 | // Returns the backing Window handle to enable clients to set icon and other 48 | // window properties. Returns nullptr if the window has been destroyed. 49 | HWND GetHandle(); 50 | 51 | // If true, closing this window will quit the application. 52 | void SetQuitOnClose(bool quit_on_close); 53 | 54 | // Return a RECT representing the bounds of the current client area. 55 | RECT GetClientArea(); 56 | 57 | protected: 58 | // Processes and route salient window messages for mouse handling, 59 | // size change and DPI. Delegates handling of these to member overloads that 60 | // inheriting classes can handle. 61 | virtual LRESULT MessageHandler(HWND window, 62 | UINT const message, 63 | WPARAM const wparam, 64 | LPARAM const lparam) noexcept; 65 | 66 | // Called when CreateAndShow is called, allowing subclass window-related 67 | // setup. Subclasses should return false if setup fails. 68 | virtual bool OnCreate(); 69 | 70 | // Called when Destroy is called. 71 | virtual void OnDestroy(); 72 | 73 | private: 74 | friend class WindowClassRegistrar; 75 | 76 | // OS callback called by message pump. Handles the WM_NCCREATE message which 77 | // is passed when the non-client area is being created and enables automatic 78 | // non-client DPI scaling so that the non-client area automatically 79 | // responsponds to changes in DPI. All other messages are handled by 80 | // MessageHandler. 81 | static LRESULT CALLBACK WndProc(HWND const window, 82 | UINT const message, 83 | WPARAM const wparam, 84 | LPARAM const lparam) noexcept; 85 | 86 | // Retrieves a class instance pointer for |window| 87 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 88 | 89 | bool quit_on_close_ = false; 90 | 91 | // window handle for top level window. 92 | HWND window_handle_ = nullptr; 93 | 94 | // window handle for hosted content. 95 | HWND child_content_ = nullptr; 96 | }; 97 | 98 | #endif // RUNNER_WIN32_WINDOW_H_ 99 | -------------------------------------------------------------------------------- /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/ephemeral/ 38 | /Flutter/flutter_export_environment.sh -------------------------------------------------------------------------------- /ios/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neckaros/secure_application/3e04524d85601fd3226e3fabadbcd09d20750619/ios/Assets/.gitkeep -------------------------------------------------------------------------------- /ios/Classes/SecureApplicationPlugin.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface SecureApplicationPlugin : NSObject 4 | @end 5 | -------------------------------------------------------------------------------- /ios/Classes/SecureApplicationPlugin.m: -------------------------------------------------------------------------------- 1 | #import "SecureApplicationPlugin.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 "secure_application-Swift.h" 9 | #endif 10 | 11 | @implementation SecureApplicationPlugin 12 | + (void)registerWithRegistrar:(NSObject*)registrar { 13 | [SwiftSecureApplicationPlugin registerWithRegistrar:registrar]; 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /ios/Classes/SwiftSecureApplicationPlugin.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | 4 | public class SwiftSecureApplicationPlugin: NSObject, FlutterPlugin { 5 | var secured = false; 6 | var opacity: CGFloat = 0.2; 7 | 8 | var backgroundTask: UIBackgroundTaskIdentifier! 9 | 10 | internal let registrar: FlutterPluginRegistrar 11 | 12 | init(registrar: FlutterPluginRegistrar) { 13 | self.registrar = registrar 14 | super.init() 15 | registrar.addApplicationDelegate(self) 16 | } 17 | 18 | public static func register(with registrar: FlutterPluginRegistrar) { 19 | let channel = FlutterMethodChannel(name: "secure_application", binaryMessenger: registrar.messenger()) 20 | let instance = SwiftSecureApplicationPlugin(registrar: registrar) 21 | registrar.addMethodCallDelegate(instance, channel: channel) 22 | } 23 | 24 | public func applicationWillResignActive(_ application: UIApplication) { 25 | if ( secured ) { 26 | self.registerBackgroundTask() 27 | UIApplication.shared.ignoreSnapshotOnNextApplicationLaunch() 28 | if let window = UIApplication.shared.windows.filter({ (w) -> Bool in 29 | return w.isHidden == false 30 | }).first { 31 | if let existingView = window.viewWithTag(99699), let existingBlurrView = window.viewWithTag(99698) { 32 | window.bringSubviewToFront(existingView) 33 | window.bringSubviewToFront(existingBlurrView) 34 | return 35 | } else { 36 | let colorView = UIView(frame: window.bounds); 37 | colorView.tag = 99699 38 | colorView.autoresizingMask = [.flexibleWidth, .flexibleHeight] 39 | colorView.backgroundColor = UIColor(white: 1, alpha: opacity) 40 | window.addSubview(colorView) 41 | window.bringSubviewToFront(colorView) 42 | 43 | let blurEffect = UIBlurEffect(style: UIBlurEffect.Style.extraLight) 44 | let blurEffectView = UIVisualEffectView(effect: blurEffect) 45 | blurEffectView.frame = window.bounds 46 | blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight] 47 | 48 | blurEffectView.tag = 99698 49 | 50 | window.addSubview(blurEffectView) 51 | window.bringSubviewToFront(blurEffectView) 52 | window.snapshotView(afterScreenUpdates: true) 53 | RunLoop.current.run(until: Date(timeIntervalSinceNow:0.5)) 54 | } 55 | } 56 | self.endBackgroundTask() 57 | } 58 | } 59 | func registerBackgroundTask() { 60 | self.backgroundTask = UIApplication.shared.beginBackgroundTask { [weak self] in 61 | self?.endBackgroundTask() 62 | } 63 | assert(self.backgroundTask != UIBackgroundTaskIdentifier.invalid) 64 | } 65 | 66 | func endBackgroundTask() { 67 | print("Background task ended.") 68 | UIApplication.shared.endBackgroundTask(backgroundTask) 69 | backgroundTask = UIBackgroundTaskIdentifier.invalid 70 | } 71 | 72 | public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { 73 | if (call.method == "secure") { 74 | secured = true; 75 | if let args = call.arguments as? Dictionary, 76 | let opacity = args["opacity"] as? NSNumber { 77 | self.opacity = opacity as! CGFloat 78 | } 79 | } else if (call.method == "open") { 80 | secured = false; 81 | } else if (call.method == "opacity") { 82 | if let args = call.arguments as? Dictionary, 83 | let opacity = args["opacity"] as? NSNumber { 84 | self.opacity = opacity as! CGFloat 85 | } 86 | } else if (call.method == "unlock") { 87 | if let window = UIApplication.shared.windows.filter({ (w) -> Bool in 88 | return w.isHidden == false 89 | }).first, let view = window.viewWithTag(99699), let blurrView = window.viewWithTag(99698) { 90 | UIView.animate(withDuration: 0.5, animations: { 91 | view.alpha = 0.0 92 | blurrView.alpha = 0.0 93 | }, completion: { finished in 94 | view.removeFromSuperview() 95 | blurrView.removeFromSuperview() 96 | 97 | }) 98 | } 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /ios/secure_application.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. 3 | # Run `pod lib lint secure_application.podspec` to validate before publishing. 4 | # 5 | Pod::Spec.new do |s| 6 | s.name = 'secure_application' 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. 21 | s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } 22 | s.swift_version = '5.0' 23 | end 24 | -------------------------------------------------------------------------------- /lib/secure_application.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/widgets.dart'; 4 | import 'package:secure_application/secure_application_native.dart'; 5 | import 'package:secure_application/secure_application_provider.dart'; 6 | import 'package:secure_application/secure_application_state.dart'; 7 | import 'package:secure_application/secure_application_controller.dart'; 8 | 9 | export './secure_application.dart'; 10 | export './secure_gate.dart'; 11 | export './secure_application_provider.dart'; 12 | export './secure_application_state.dart'; 13 | export './secure_application_controller.dart'; 14 | 15 | /// Widget that will manage Secure Gates and visibility protection for your app content 16 | /// 17 | /// Should be above any [SecureGate] 18 | /// provide to all it descendants a [SecureApplicationController] that can be used to secure/open and lock/unlock 19 | class SecureApplication extends StatefulWidget { 20 | /// Child of the widget 21 | final Widget child; 22 | 23 | /// This will remove IOs glass effect from native automatically. To set to true (default) if you don't want to manage it 24 | /// you can play with the [nativeRemoveDelay] to avoid iOS unsecure flicker 25 | final bool autoUnlockNative; 26 | 27 | /// Method will be called when the user switch back to your application 28 | /// 29 | /// you can manage from here a global process for authorizing the user to see hidden content 30 | /// like maybe by using local_auth package 31 | final Future? Function( 32 | SecureApplicationController? secureApplicationStateNotifier)? 33 | onNeedUnlock; 34 | 35 | /// will be called if authentication failed 36 | final VoidCallback? onAuthenticationFailed; 37 | 38 | /// will be called if authentication succeed 39 | final VoidCallback? onAuthenticationSucceed; 40 | 41 | /// will be called if user logout 42 | final VoidCallback? onLogout; 43 | 44 | /// the time in milliseconds we wait to remove the native protection screen 45 | /// usefull on iOS to let long app start 46 | final int nativeRemoveDelay; 47 | 48 | /// controller of the [SecureApplication] 49 | /// 50 | /// Can be set to provide your own controller to the application 51 | /// with your own starting values 52 | final SecureApplicationController? secureApplicationController; 53 | const SecureApplication({ 54 | Key? key, 55 | required this.child, 56 | this.onNeedUnlock, 57 | this.secureApplicationController, 58 | this.autoUnlockNative = true, 59 | this.onAuthenticationFailed, 60 | this.onAuthenticationSucceed, 61 | this.onLogout, 62 | this.nativeRemoveDelay = 1000, 63 | }) : super(key: key); 64 | 65 | @override 66 | _SecureApplicationState createState() => _SecureApplicationState(); 67 | } 68 | 69 | class _SecureApplicationState extends State 70 | with WidgetsBindingObserver { 71 | SecureApplicationController? _secureApplicationController; 72 | 73 | StreamSubscription? _authStreamSubscription; 74 | 75 | SecureApplicationController get secureApplicationController { 76 | if (widget.secureApplicationController != null) { 77 | return widget.secureApplicationController!; 78 | } else if (_secureApplicationController != null) { 79 | return _secureApplicationController!; 80 | } 81 | _secureApplicationController = 82 | SecureApplicationController(SecureApplicationState()); 83 | return _secureApplicationController!; 84 | } 85 | 86 | bool _removeNativeOnNextFrame = false; 87 | @override 88 | void initState() { 89 | _authStreamSubscription = 90 | secureApplicationController.authenticationEvents.listen((s) { 91 | if (s == SecureApplicationAuthenticationStatus.FAILED) { 92 | if (widget.onAuthenticationFailed != null) 93 | widget.onAuthenticationFailed!(); 94 | } else if (s == SecureApplicationAuthenticationStatus.SUCCESS) { 95 | if (widget.onAuthenticationSucceed != null) 96 | widget.onAuthenticationSucceed!(); 97 | } else if (s == SecureApplicationAuthenticationStatus.LOGOUT) { 98 | if (widget.onLogout != null) widget.onLogout!(); 99 | } 100 | }); 101 | super.initState(); 102 | WidgetsBinding.instance.addObserver(this); 103 | SecureApplicationNative.registerForEvents( 104 | secureApplicationController.lockIfSecured, 105 | secureApplicationController.unlock); 106 | } 107 | 108 | @override 109 | void dispose() { 110 | _authStreamSubscription?.cancel(); 111 | super.dispose(); 112 | WidgetsBinding.instance.removeObserver(this); 113 | } 114 | 115 | @override 116 | void didChangeAppLifecycleState(AppLifecycleState state) async { 117 | switch (state) { 118 | case AppLifecycleState.resumed: 119 | if (mounted) { 120 | setState(() => _removeNativeOnNextFrame = true); 121 | } else { 122 | _removeNativeOnNextFrame = true; 123 | } 124 | if (!secureApplicationController.paused) { 125 | if (secureApplicationController.secured && 126 | secureApplicationController.value.locked) { 127 | if (widget.onNeedUnlock != null) { 128 | secureApplicationController.pause(); 129 | var authStatus = 130 | await widget.onNeedUnlock!(secureApplicationController); 131 | if (authStatus != null) 132 | secureApplicationController.sendAuthenticationEvent(authStatus); 133 | 134 | WidgetsBinding.instance.addPostFrameCallback((_) { 135 | secureApplicationController.unpause(); 136 | }); 137 | } 138 | } 139 | secureApplicationController.resumed(); 140 | } 141 | super.didChangeAppLifecycleState(state); 142 | break; 143 | case AppLifecycleState.paused: 144 | if (!secureApplicationController.paused) { 145 | if (secureApplicationController.secured) { 146 | secureApplicationController.lock(); 147 | } 148 | } 149 | super.didChangeAppLifecycleState(state); 150 | break; 151 | default: 152 | super.didChangeAppLifecycleState(state); 153 | break; 154 | } 155 | } 156 | 157 | @override 158 | Widget build(BuildContext context) { 159 | if (_removeNativeOnNextFrame && widget.autoUnlockNative) { 160 | Future.delayed(Duration(milliseconds: widget.nativeRemoveDelay)) 161 | .then((_) => SecureApplicationNative.unlock()); 162 | 163 | _removeNativeOnNextFrame = false; 164 | } 165 | return SecureApplicationProvider( 166 | secureData: secureApplicationController, 167 | child: widget.child, 168 | ); 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /lib/secure_application_controller.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/foundation.dart'; 4 | import 'package:rxdart/rxdart.dart'; 5 | import 'package:secure_application/secure_application_native.dart'; 6 | import 'package:secure_application/secure_application_state.dart'; 7 | 8 | enum SecureApplicationAuthenticationStatus { SUCCESS, FAILED, LOGOUT, NONE } 9 | 10 | /// main controller for the library 11 | /// 12 | /// secured mean that the application will lock if the user switch out of the app 13 | /// on Android it will prevent user from taking screenshot/recordvideo in the app 14 | /// on iOS/Android it will hide content in the app switcher 15 | /// on iOS/Android it will lock [SecureApplicationController.locked] = true when it become active again 16 | /// when locked if a gate depends on this controller it will display the blurry gate to obfuscate content 17 | class SecureApplicationController 18 | extends ValueNotifier { 19 | SecureApplicationController(SecureApplicationState value) : super(value); 20 | 21 | final BehaviorSubject 22 | _authenticationEventsController = 23 | BehaviorSubject.seeded( 24 | SecureApplicationAuthenticationStatus.NONE); 25 | 26 | /// Broadcast stream that you can use to react to succesffull or unsuccessfull event 27 | /// default to [SecureApplicationAuthenticationStatus.NONE] 28 | /// [BehaviorSubject] stream so it will always emit last sent value as soon as you listen 29 | /// will trigger with the result of [SecureApllication.onNeedUnlock] 30 | Stream get authenticationEvents => 31 | _authenticationEventsController.stream; 32 | 33 | final BehaviorSubject _lockEventsController = 34 | BehaviorSubject.seeded(false); 35 | 36 | /// Broadcast stream that you can use to react to lock/unlock event 37 | /// default to [false] 38 | /// [BehaviorSubject] stream so it will always emit last sent value as soon as you listen 39 | Stream get lockEvents => _lockEventsController.stream; 40 | 41 | /// Is the application Locked 42 | /// if locked gates will hide their children content 43 | /// will be automatically set to yes when user switch back to app 44 | /// can be triggered with [lock()] manually to activates gates on your own volution 45 | bool get locked => value.locked; 46 | 47 | /// Is the application secured 48 | bool get secured => value.secured; 49 | 50 | /// if paused lock will not be set when they get back to the app 51 | /// could be usefull for example when you open an image or file picker 52 | bool get paused => value.paused; 53 | 54 | /// helper that hold las authentication status 55 | /// default to false 56 | /// allow you to hide or show content depending on authentication status 57 | bool get authenticated => value.authenticated; 58 | 59 | /// notify listener of the [SecureApplicationController.authenticationEvents] of a failure or success 60 | /// to allow them for example to clear sensitive data 61 | void sendAuthenticationEvent(SecureApplicationAuthenticationStatus status) { 62 | _authenticationEventsController.add(status); 63 | } 64 | 65 | void authFailed({bool unlock = false}) { 66 | value = value.copyWith(authenticated: false); 67 | _authenticationEventsController 68 | .add(SecureApplicationAuthenticationStatus.FAILED); 69 | if (unlock) { 70 | this.unlock(); 71 | } 72 | notifyListeners(); 73 | } 74 | 75 | void authSuccess({bool unlock = false}) { 76 | value = value.copyWith(authenticated: true); 77 | _authenticationEventsController 78 | .add(SecureApplicationAuthenticationStatus.SUCCESS); 79 | if (unlock) { 80 | this.unlock(); 81 | } 82 | notifyListeners(); 83 | } 84 | 85 | void authLogout({bool unlock = false}) { 86 | value = value.copyWith(authenticated: false); 87 | _authenticationEventsController 88 | .add(SecureApplicationAuthenticationStatus.LOGOUT); 89 | if (unlock) { 90 | this.unlock(); 91 | } 92 | notifyListeners(); 93 | } 94 | 95 | /// content under [SecureGate] will not be visible 96 | void lock() { 97 | SecureApplicationNative.lock(); 98 | if (!value.locked) { 99 | value = value.copyWith(locked: true); 100 | notifyListeners(); 101 | _lockEventsController.add(true); 102 | } 103 | } 104 | 105 | void lockIfSecured() { 106 | if (value.secured) lock(); 107 | } 108 | 109 | /// Use when you want your user to see content under [SecureGate] 110 | void unlock() { 111 | SecureApplicationNative 112 | .unlock(); //lock from native is removed when resumed but why not! 113 | if (value.locked) { 114 | value = value.copyWith(locked: false); 115 | notifyListeners(); 116 | _lockEventsController.add(false); 117 | } 118 | } 119 | 120 | /// temporary prevent the app from locking if use leave and come back to the app 121 | void pause() { 122 | SecureApplicationNative.lock(); 123 | if (!value.paused) { 124 | value = value.copyWith(paused: true); 125 | notifyListeners(); 126 | } 127 | } 128 | 129 | /// app switching will again provoque a lock 130 | void unpause() { 131 | if (value.paused) { 132 | value = value.copyWith(paused: false); 133 | notifyListeners(); 134 | } 135 | } 136 | 137 | /// Use to warn gates that the app resumed 138 | /// used internally only 139 | void resumed() { 140 | notifyListeners(); 141 | } 142 | 143 | /// App will be secured and content will not be visible if user switch app 144 | /// 145 | /// on Android this will also prevent scrensshot/screen recording 146 | void secure() { 147 | SecureApplicationNative.secure(); 148 | if (!value.secured) { 149 | value = value.copyWith(secured: true); 150 | notifyListeners(); 151 | } 152 | } 153 | 154 | /// App will no longer be secured and content will be visible if user switch app 155 | void open() { 156 | SecureApplicationNative.open(); 157 | if (value.secured) { 158 | value = value.copyWith(secured: false); 159 | notifyListeners(); 160 | } 161 | } 162 | 163 | @override 164 | void dispose() { 165 | _authenticationEventsController.close(); 166 | _lockEventsController.close(); 167 | super.dispose(); 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /lib/secure_application_native.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/services.dart'; 4 | 5 | class SecureApplicationNative { 6 | static const MethodChannel _channel = 7 | const MethodChannel('secure_application'); 8 | 9 | static void registerForEvents(VoidCallback lock, VoidCallback unlock) { 10 | _channel.setMethodCallHandler( 11 | (call) => secureApplicationHandler(call, lock, unlock)); 12 | } 13 | 14 | static Future secureApplicationHandler( 15 | MethodCall methodCall, lock, unlock) async { 16 | switch (methodCall.method) { 17 | case 'lock': 18 | lock(); 19 | break; 20 | case 'unlock': 21 | unlock(); 22 | break; 23 | default: 24 | throw MissingPluginException('notImplemented'); 25 | } 26 | } 27 | 28 | static Future secure() { 29 | return _channel.invokeMethod('secure'); 30 | } 31 | 32 | static Future open() { 33 | return _channel.invokeMethod('open'); 34 | } 35 | 36 | static Future lock() { 37 | return _channel.invokeMethod('lock'); 38 | } 39 | 40 | static Future unlock() { 41 | return _channel.invokeMethod('unlock'); 42 | } 43 | 44 | static Future opacity(double opacity) { 45 | return _channel.invokeMethod('opacity', {"opacity": opacity}); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /lib/secure_application_provider.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | import 'package:secure_application/secure_application_controller.dart'; 3 | 4 | /// [InheritedWidget] provider of a [SecureApplicationController] for its children. 5 | /// 6 | /// Used internally by [SecureApplication] 7 | class SecureApplicationProvider extends InheritedWidget { 8 | const SecureApplicationProvider({ 9 | Key? key, 10 | this.secureData, 11 | required Widget child, 12 | }) : super(key: key, child: child); 13 | 14 | final SecureApplicationController? secureData; 15 | 16 | /// get the [SecureApplicationController] of the context 17 | /// Use [listen] = false if you are outside of a widget builder (example in init state or in a bloc) 18 | static SecureApplicationController? of(BuildContext context, 19 | {bool listen = true}) { 20 | if (listen) { 21 | return context 22 | .dependOnInheritedWidgetOfExactType()! 23 | .secureData; 24 | } else { 25 | var widget = context 26 | .getElementForInheritedWidgetOfExactType()! 27 | .widget as SecureApplicationProvider; 28 | return widget.secureData; 29 | } 30 | } 31 | 32 | @override 33 | bool updateShouldNotify(SecureApplicationProvider old) => 34 | old.secureData != secureData; 35 | } 36 | -------------------------------------------------------------------------------- /lib/secure_application_state.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | 3 | /// state hold by the [SecureApplicationController] 4 | @immutable 5 | class SecureApplicationState { 6 | final bool locked; 7 | final bool secured; 8 | final bool paused; 9 | final bool authenticated; 10 | SecureApplicationState({ 11 | this.locked = false, 12 | this.secured = false, 13 | this.paused = false, 14 | this.authenticated = false, 15 | }); 16 | 17 | SecureApplicationState copyWith({ 18 | bool? locked, 19 | bool? secured, 20 | bool? paused, 21 | bool? authenticated, 22 | }) { 23 | return SecureApplicationState( 24 | locked: locked ?? this.locked, 25 | secured: secured ?? this.secured, 26 | paused: paused ?? this.paused, 27 | authenticated: authenticated ?? this.authenticated, 28 | ); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lib/secure_application_web.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | // In order to *not* need this ignore, consider extracting the "web" version 3 | // of your plugin as a separate package, instead of inlining it in the same 4 | // package as the core of your plugin. 5 | // ignore: avoid_web_libraries_in_flutter 6 | import 'dart:html' as html show window, document, Event; 7 | 8 | import 'package:flutter/services.dart'; 9 | import 'package:flutter_web_plugins/flutter_web_plugins.dart'; 10 | 11 | /// A web implementation of the SecureApplication plugin. 12 | class SecureApplicationWeb { 13 | bool secured = false; 14 | StreamSubscription? onVC; 15 | final MethodChannel _channel; 16 | SecureApplicationWeb(this._channel); 17 | 18 | void secureApplication() { 19 | onVC?.cancel(); 20 | onVC = html.document.onVisibilityChange.listen(visibilityEvent); 21 | secured = true; 22 | } 23 | 24 | void visibilityEvent(html.Event e) { 25 | if (html.document.visibilityState == 'hidden') 26 | _channel.invokeMethod('lock', 'web'); 27 | } 28 | 29 | void unsecureApplication() { 30 | onVC?.cancel(); 31 | secured = false; 32 | } 33 | 34 | static void registerWith(Registrar registrar) { 35 | final MethodChannel channel = MethodChannel( 36 | 'secure_application', 37 | const StandardMethodCodec(), 38 | registrar, 39 | ); 40 | 41 | final pluginInstance = SecureApplicationWeb(channel); 42 | channel.setMethodCallHandler(pluginInstance.handleMethodCall); 43 | } 44 | 45 | /// Handles method calls over the MethodChannel of this plugin. 46 | /// Note: Check the "federated" architecture for a new way of doing this: 47 | /// https://flutter.dev/go/federated-plugins 48 | Future handleMethodCall(MethodCall call) async { 49 | switch (call.method) { 50 | case 'secure': 51 | secureApplication(); 52 | return true; 53 | case 'open': 54 | unsecureApplication(); 55 | return true; 56 | default: 57 | return true; 58 | // throw PlatformException( 59 | // code: 'Unimplemented', 60 | // details: 'secure_application for web doesn\'t implement \'${call.method}\'', 61 | // ); 62 | } 63 | } 64 | 65 | /// Returns a [String] containing the version of the platform. 66 | Future getPlatformVersion() { 67 | final version = html.window.navigator.userAgent; 68 | return Future.value(version); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /lib/secure_gate.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:secure_application/secure_application_native.dart'; 5 | import 'package:secure_application/secure_application_provider.dart'; 6 | import 'package:secure_application/secure_application_controller.dart'; 7 | 8 | /// it will display a blurr over your content if locked 9 | /// 10 | /// It will lock/unlock depending on the [SecureApplicationController] provided by a [SecureApplication] 11 | /// above this controller 12 | /// play with [SecureGate.opacity] and [SecureGate.blurr] to controle amount of child visible when the gate is active 13 | class SecureGate extends StatefulWidget { 14 | /// child to display if not locked 15 | final Widget child; 16 | 17 | /// builder to display a child above the blurr window to allow your user to authenticate and unlock 18 | /// use the provided [SecureApplicationController] to unlock [SecureApplicationController] when user is authenticated 19 | final Widget Function(BuildContext context, 20 | SecureApplicationController? secureApplicationController)? lockedBuilder; 21 | 22 | /// amount of blurr to allow more or less of the child be visible when locked 23 | /// default to 20 24 | final double blurr; 25 | 26 | /// opacity of the blurr gate 27 | /// default to 0.6 28 | final double opacity; 29 | 30 | const SecureGate({ 31 | Key? key, 32 | required this.child, 33 | this.blurr = 20, 34 | this.opacity = 0.6, 35 | this.lockedBuilder, 36 | }) : super(key: key); 37 | @override 38 | _SecureGateState createState() => _SecureGateState(); 39 | } 40 | 41 | class _SecureGateState extends State 42 | with SingleTickerProviderStateMixin { 43 | bool _lock = false; 44 | late AnimationController _gateVisibility; 45 | SecureApplicationController? _secureApplicationController; 46 | 47 | @override 48 | void initState() { 49 | _gateVisibility = 50 | AnimationController(vsync: this, duration: kThemeAnimationDuration * 2) 51 | ..addListener(_handleChange); 52 | SecureApplicationNative.opacity(widget.opacity); 53 | 54 | super.initState(); 55 | } 56 | 57 | @override 58 | void didChangeDependencies() { 59 | if (_secureApplicationController == null) { 60 | _secureApplicationController = SecureApplicationProvider.of(context); 61 | _secureApplicationController!.addListener(_sercureNotified); 62 | _sercureNotified(); 63 | } 64 | super.didChangeDependencies(); 65 | } 66 | 67 | @override 68 | void didUpdateWidget(SecureGate oldWidget) { 69 | super.didUpdateWidget(oldWidget); 70 | if (oldWidget.opacity != widget.opacity) { 71 | SecureApplicationNative.opacity(widget.opacity); 72 | } 73 | } 74 | 75 | void _sercureNotified() { 76 | if (_lock == false && _secureApplicationController!.locked == true) { 77 | _lock = true; 78 | _gateVisibility.value = 1; 79 | } else if (_lock == true && _secureApplicationController!.locked == false) { 80 | _lock = false; 81 | _gateVisibility.animateBack(0).orCancel; 82 | } 83 | } 84 | 85 | void _handleChange() { 86 | setState(() { 87 | // The listenable's state is our build state, and it changed already. 88 | }); 89 | } 90 | 91 | @override 92 | void dispose() { 93 | _secureApplicationController!.removeListener(_sercureNotified); 94 | _gateVisibility.dispose(); 95 | super.dispose(); 96 | } 97 | 98 | @override 99 | Widget build(BuildContext context) { 100 | return Stack( 101 | children: [ 102 | widget.child, 103 | if (_gateVisibility.value != 0) 104 | Positioned.fill( 105 | child: BackdropFilter( 106 | filter: ImageFilter.blur( 107 | sigmaX: widget.blurr * _gateVisibility.value, 108 | sigmaY: widget.blurr * _gateVisibility.value), 109 | child: Container( 110 | decoration: BoxDecoration( 111 | color: Colors.grey.shade200 112 | .withOpacity(widget.opacity * _gateVisibility.value)), 113 | ), 114 | ), 115 | ), 116 | if (_lock && widget.lockedBuilder != null) 117 | widget.lockedBuilder!(context, _secureApplicationController), 118 | ], 119 | ); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63 9 | url: "https://pub.dev" 10 | source: hosted 11 | version: "2.12.0" 12 | boolean_selector: 13 | dependency: transitive 14 | description: 15 | name: boolean_selector 16 | sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" 17 | url: "https://pub.dev" 18 | source: hosted 19 | version: "2.1.2" 20 | characters: 21 | dependency: transitive 22 | description: 23 | name: characters 24 | sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 25 | url: "https://pub.dev" 26 | source: hosted 27 | version: "1.4.0" 28 | clock: 29 | dependency: transitive 30 | description: 31 | name: clock 32 | sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b 33 | url: "https://pub.dev" 34 | source: hosted 35 | version: "1.1.2" 36 | collection: 37 | dependency: transitive 38 | description: 39 | name: collection 40 | sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" 41 | url: "https://pub.dev" 42 | source: hosted 43 | version: "1.19.1" 44 | fake_async: 45 | dependency: transitive 46 | description: 47 | name: fake_async 48 | sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc" 49 | url: "https://pub.dev" 50 | source: hosted 51 | version: "1.3.2" 52 | flutter: 53 | dependency: "direct main" 54 | description: flutter 55 | source: sdk 56 | version: "0.0.0" 57 | flutter_plugin_android_lifecycle: 58 | dependency: "direct main" 59 | description: 60 | name: flutter_plugin_android_lifecycle 61 | sha256: "5a1e6fb2c0561958d7e4c33574674bda7b77caaca7a33b758876956f2902eea3" 62 | url: "https://pub.dev" 63 | source: hosted 64 | version: "2.0.27" 65 | flutter_test: 66 | dependency: "direct dev" 67 | description: flutter 68 | source: sdk 69 | version: "0.0.0" 70 | flutter_web_plugins: 71 | dependency: "direct main" 72 | description: flutter 73 | source: sdk 74 | version: "0.0.0" 75 | leak_tracker: 76 | dependency: transitive 77 | description: 78 | name: leak_tracker 79 | sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec 80 | url: "https://pub.dev" 81 | source: hosted 82 | version: "10.0.8" 83 | leak_tracker_flutter_testing: 84 | dependency: transitive 85 | description: 86 | name: leak_tracker_flutter_testing 87 | sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573 88 | url: "https://pub.dev" 89 | source: hosted 90 | version: "3.0.9" 91 | leak_tracker_testing: 92 | dependency: transitive 93 | description: 94 | name: leak_tracker_testing 95 | sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" 96 | url: "https://pub.dev" 97 | source: hosted 98 | version: "3.0.1" 99 | matcher: 100 | dependency: transitive 101 | description: 102 | name: matcher 103 | sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 104 | url: "https://pub.dev" 105 | source: hosted 106 | version: "0.12.17" 107 | material_color_utilities: 108 | dependency: transitive 109 | description: 110 | name: material_color_utilities 111 | sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec 112 | url: "https://pub.dev" 113 | source: hosted 114 | version: "0.11.1" 115 | meta: 116 | dependency: transitive 117 | description: 118 | name: meta 119 | sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c 120 | url: "https://pub.dev" 121 | source: hosted 122 | version: "1.16.0" 123 | path: 124 | dependency: transitive 125 | description: 126 | name: path 127 | sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" 128 | url: "https://pub.dev" 129 | source: hosted 130 | version: "1.9.1" 131 | rxdart: 132 | dependency: "direct main" 133 | description: 134 | name: rxdart 135 | sha256: "5c3004a4a8dbb94bd4bf5412a4def4acdaa12e12f269737a5751369e12d1a962" 136 | url: "https://pub.dev" 137 | source: hosted 138 | version: "0.28.0" 139 | sky_engine: 140 | dependency: transitive 141 | description: flutter 142 | source: sdk 143 | version: "0.0.0" 144 | source_span: 145 | dependency: transitive 146 | description: 147 | name: source_span 148 | sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c" 149 | url: "https://pub.dev" 150 | source: hosted 151 | version: "1.10.1" 152 | stack_trace: 153 | dependency: transitive 154 | description: 155 | name: stack_trace 156 | sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" 157 | url: "https://pub.dev" 158 | source: hosted 159 | version: "1.12.1" 160 | stream_channel: 161 | dependency: transitive 162 | description: 163 | name: stream_channel 164 | sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" 165 | url: "https://pub.dev" 166 | source: hosted 167 | version: "2.1.4" 168 | string_scanner: 169 | dependency: transitive 170 | description: 171 | name: string_scanner 172 | sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" 173 | url: "https://pub.dev" 174 | source: hosted 175 | version: "1.4.1" 176 | term_glyph: 177 | dependency: transitive 178 | description: 179 | name: term_glyph 180 | sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" 181 | url: "https://pub.dev" 182 | source: hosted 183 | version: "1.2.2" 184 | test_api: 185 | dependency: transitive 186 | description: 187 | name: test_api 188 | sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd 189 | url: "https://pub.dev" 190 | source: hosted 191 | version: "0.7.4" 192 | vector_math: 193 | dependency: transitive 194 | description: 195 | name: vector_math 196 | sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" 197 | url: "https://pub.dev" 198 | source: hosted 199 | version: "2.1.4" 200 | vm_service: 201 | dependency: transitive 202 | description: 203 | name: vm_service 204 | sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14" 205 | url: "https://pub.dev" 206 | source: hosted 207 | version: "14.3.1" 208 | sdks: 209 | dart: ">=3.7.0-0 <4.0.0" 210 | flutter: ">=3.27.0" 211 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: secure_application 2 | description: Secure app content visibility when user leave app. It will hide content 3 | in the app switcher and display a frost barrier above locked content when the user get backs 4 | version: 4.1.0 5 | homepage: https://github.com/neckaros/secure_application 6 | 7 | environment: 8 | sdk: ">=2.12.0 <4.0.0" 9 | flutter: ">=3.0.0" 10 | 11 | dependencies: 12 | flutter: 13 | sdk: flutter 14 | flutter_web_plugins: 15 | sdk: flutter 16 | flutter_plugin_android_lifecycle: ^2.0.23 17 | rxdart: ^0.28.0 18 | 19 | dev_dependencies: 20 | flutter_test: 21 | sdk: flutter 22 | flutter: 23 | plugin: 24 | platforms: 25 | android: 26 | package: org.jezequel.secure_application 27 | pluginClass: SecureApplicationPlugin 28 | ios: 29 | pluginClass: SecureApplicationPlugin 30 | web: 31 | pluginClass: SecureApplicationWeb 32 | fileName: secure_application_web.dart 33 | windows: 34 | pluginClass: SecureApplicationPlugin 35 | -------------------------------------------------------------------------------- /test/secure_application_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/services.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | 4 | void main() { 5 | const MethodChannel channel = MethodChannel('secure_application'); 6 | 7 | TestWidgetsFlutterBinding.ensureInitialized(); 8 | 9 | setUp(() { 10 | channel.setMockMethodCallHandler((MethodCall methodCall) async { 11 | return '42'; 12 | }); 13 | }); 14 | 15 | tearDown(() { 16 | channel.setMockMethodCallHandler(null); 17 | }); 18 | } 19 | -------------------------------------------------------------------------------- /test/secure_window_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/services.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | 4 | void main() { 5 | const MethodChannel channel = MethodChannel('secure_application'); 6 | 7 | TestWidgetsFlutterBinding.ensureInitialized(); 8 | 9 | setUp(() { 10 | channel.setMockMethodCallHandler((MethodCall methodCall) async { 11 | return '42'; 12 | }); 13 | }); 14 | 15 | tearDown(() { 16 | channel.setMockMethodCallHandler(null); 17 | }); 18 | 19 | test('getPlatformVersion', () async {}); 20 | } 21 | -------------------------------------------------------------------------------- /windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15) 2 | set(PROJECT_NAME "secure_application") 3 | project(${PROJECT_NAME} LANGUAGES CXX) 4 | 5 | # This value is used when generating builds using this plugin, so it must 6 | # not be changed 7 | set(PLUGIN_NAME "secure_application_plugin") 8 | 9 | add_library(${PLUGIN_NAME} SHARED 10 | "secure_application_plugin.cpp" 11 | ) 12 | apply_standard_settings(${PLUGIN_NAME}) 13 | set_target_properties(${PLUGIN_NAME} PROPERTIES 14 | CXX_VISIBILITY_PRESET hidden) 15 | target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL) 16 | target_include_directories(${PLUGIN_NAME} INTERFACE 17 | "${CMAKE_CURRENT_SOURCE_DIR}/include") 18 | target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin) 19 | 20 | # List of absolute paths to libraries that should be bundled with the plugin 21 | set(secure_application_bundled_libraries 22 | "" 23 | PARENT_SCOPE 24 | ) 25 | -------------------------------------------------------------------------------- /windows/include/secure_application/secure_application_plugin.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_PLUGIN_SECURE_APPLICATION_PLUGIN_H_ 2 | #define FLUTTER_PLUGIN_SECURE_APPLICATION_PLUGIN_H_ 3 | 4 | #include 5 | 6 | #ifdef FLUTTER_PLUGIN_IMPL 7 | #define FLUTTER_PLUGIN_EXPORT __declspec(dllexport) 8 | #else 9 | #define FLUTTER_PLUGIN_EXPORT __declspec(dllimport) 10 | #endif 11 | 12 | #if defined(__cplusplus) 13 | extern "C" { 14 | #endif 15 | 16 | FLUTTER_PLUGIN_EXPORT void SecureApplicationPluginRegisterWithRegistrar( 17 | FlutterDesktopPluginRegistrarRef registrar); 18 | 19 | #if defined(__cplusplus) 20 | } // extern "C" 21 | #endif 22 | 23 | #endif // FLUTTER_PLUGIN_SECURE_APPLICATION_PLUGIN_H_ 24 | -------------------------------------------------------------------------------- /windows/secure_application_plugin.cpp: -------------------------------------------------------------------------------- 1 | #include "include/secure_application/secure_application_plugin.h" 2 | 3 | // This must be included before many other Windows headers. 4 | #include 5 | 6 | // For getPlatformVersion; remove unless needed for your plugin implementation. 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | using namespace std; 19 | 20 | namespace 21 | { 22 | HHOOK flutterWindowMonitor = nullptr; 23 | HWINEVENTHOOK switchHook = nullptr; 24 | std::unique_ptr, std::default_delete>> channel = nullptr; 25 | 26 | class SecureApplicationPlugin : public flutter::Plugin 27 | { 28 | public: 29 | static void RegisterWithRegistrar(flutter::PluginRegistrarWindows *registrar); 30 | 31 | SecureApplicationPlugin(); 32 | 33 | virtual ~SecureApplicationPlugin(); 34 | 35 | private: 36 | static LRESULT CALLBACK monitorFlutterWindowsProc(int nCode, WPARAM wParam, LPARAM lParam); 37 | static void CALLBACK winEventProcCallback(HWINEVENTHOOK hWinEventHook, DWORD event, HWND hwnd, LONG idObject, LONG idChild, DWORD idEventThread, DWORD dwmsEventTime); 38 | // Called when a method is called on this plugin's channel from Dart. 39 | void HandleMethodCall( 40 | const flutter::MethodCall &method_call, 41 | std::unique_ptr> result); 42 | }; 43 | 44 | // static 45 | void SecureApplicationPlugin::RegisterWithRegistrar( 46 | flutter::PluginRegistrarWindows *registrar) 47 | { 48 | channel = 49 | std::make_unique>( 50 | registrar->messenger(), "secure_application", 51 | &flutter::StandardMethodCodec::GetInstance()); 52 | 53 | auto plugin = std::make_unique(); 54 | 55 | channel->SetMethodCallHandler( 56 | [plugin_pointer = plugin.get()](const auto &call, auto result) { 57 | plugin_pointer->HandleMethodCall(call, std::move(result)); 58 | }); 59 | 60 | registrar->AddPlugin(std::move(plugin)); 61 | } 62 | 63 | SecureApplicationPlugin::SecureApplicationPlugin() 64 | { 65 | DWORD threadID = GetCurrentThreadId(); 66 | flutterWindowMonitor = SetWindowsHookEx(WH_CBT, &monitorFlutterWindowsProc, NULL, threadID); 67 | switchHook = SetWinEventHook(EVENT_SYSTEM_DESKTOPSWITCH, EVENT_SYSTEM_DESKTOPSWITCH, NULL, &winEventProcCallback, 0, 0, WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS); 68 | } 69 | 70 | SecureApplicationPlugin::~SecureApplicationPlugin() 71 | { 72 | UnhookWindowsHookEx(flutterWindowMonitor); 73 | } 74 | void CALLBACK SecureApplicationPlugin::winEventProcCallback(HWINEVENTHOOK hWinEventHook, DWORD dwEvent, HWND hwnd, LONG idObject, LONG idChild, DWORD dwEventThread, DWORD dwmsEventTime) 75 | { 76 | channel->InvokeMethod("lock", nullptr); 77 | } 78 | 79 | LRESULT CALLBACK SecureApplicationPlugin::monitorFlutterWindowsProc( 80 | _In_ int code, 81 | _In_ WPARAM wparam, 82 | _In_ LPARAM lparam) 83 | { 84 | //if ( WM_SYSCOMMAND 85 | if (code == HCBT_SYSCOMMAND) 86 | { 87 | if (SC_MINIMIZE == wparam) 88 | { 89 | channel->InvokeMethod("lock", nullptr); 90 | } 91 | } 92 | return 0; 93 | } 94 | 95 | void SecureApplicationPlugin::HandleMethodCall( 96 | const flutter::MethodCall &method_call, 97 | std::unique_ptr> result) 98 | { 99 | if (method_call.method_name().compare("getPlatformVersion") == 0) 100 | { 101 | std::ostringstream version_stream; 102 | version_stream << "Windows "; 103 | if (IsWindows10OrGreater()) 104 | { 105 | version_stream << "10+"; 106 | } 107 | else if (IsWindows8OrGreater()) 108 | { 109 | version_stream << "8"; 110 | } 111 | else if (IsWindows7OrGreater()) 112 | { 113 | version_stream << "7"; 114 | } 115 | result->Success(flutter::EncodableValue(version_stream.str())); 116 | } 117 | else 118 | { 119 | result->Success(); 120 | } 121 | } 122 | 123 | } // namespace 124 | 125 | void SecureApplicationPluginRegisterWithRegistrar( 126 | FlutterDesktopPluginRegistrarRef registrar) 127 | { 128 | SecureApplicationPlugin::RegisterWithRegistrar( 129 | flutter::PluginRegistrarManager::GetInstance() 130 | ->GetRegistrar(registrar)); 131 | } 132 | --------------------------------------------------------------------------------