├── .clang-format ├── .github └── FUNDING.yml ├── .gitignore ├── LICENSE ├── README-ZH.md ├── README.md ├── melos.yaml ├── packages ├── shortcut_menu_extender │ ├── .gitignore │ ├── .metadata │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README-ZH.md │ ├── README.md │ ├── analysis_options.yaml │ ├── example │ │ ├── .gitignore │ │ ├── .metadata │ │ ├── README.md │ │ ├── analysis_options.yaml │ │ ├── integration_test │ │ │ └── plugin_integration_test.dart │ │ ├── lib │ │ │ └── main.dart │ │ ├── pubspec.lock │ │ ├── pubspec.yaml │ │ ├── test │ │ │ └── widget_test.dart │ │ └── 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 │ │ │ ├── runner.exe.manifest │ │ │ ├── utils.cpp │ │ │ ├── utils.h │ │ │ ├── win32_window.cpp │ │ │ └── win32_window.h │ ├── lib │ │ ├── shortcut_menu_extender.dart │ │ └── src │ │ │ └── shortcut_menu_extender.dart │ └── pubspec.yaml ├── shortcut_menu_extender_platform_interface │ ├── .gitignore │ ├── .metadata │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── analysis_options.yaml │ ├── lib │ │ ├── shortcut_menu_extender_platform_interface.dart │ │ └── src │ │ │ ├── shortcut_menu_extender_method_channel.dart │ │ │ ├── shortcut_menu_extender_platform.dart │ │ │ └── shortcut_menu_listener.dart │ └── pubspec.yaml └── shortcut_menu_extender_windows │ ├── .gitignore │ ├── .metadata │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── analysis_options.yaml │ ├── lib │ ├── shortcut_menu_extender_windows.dart │ └── src │ │ ├── shortcut_menu_extender_command.dart │ │ └── shortcut_menu_extender_windows.dart │ ├── pubspec.yaml │ ├── test │ └── src │ │ └── shortcut_menu_extender_command_test.dart │ └── windows │ ├── .gitignore │ ├── CMakeLists.txt │ ├── include │ └── shortcut_menu_extender_windows │ │ └── shortcut_menu_extender_windows_plugin_c_api.h │ ├── shortcut_menu_extender_windows_plugin.cpp │ ├── shortcut_menu_extender_windows_plugin.h │ ├── shortcut_menu_extender_windows_plugin_c_api.cpp │ └── test │ └── shortcut_menu_extender_windows_plugin_test.cpp ├── pubspec.lock └── pubspec.yaml /.clang-format: -------------------------------------------------------------------------------- 1 | # Defines the Chromium style for automatic reformatting. 2 | # http://clang.llvm.org/docs/ClangFormatStyleOptions.html 3 | BasedOnStyle: Chromium 4 | # This defaults to 'Auto'. Explicitly set it for a while, so that 5 | # 'vector >' in existing files gets formatted to 6 | # 'vector>'. ('Auto' means that clang-format will only use 7 | # 'int>>' if the file already contains at least one such instance.) 8 | Standard: Cpp11 9 | SortIncludes: true 10 | --- 11 | Language: ObjC 12 | ColumnLimit: 100 13 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | liberapay: lijy91 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .dart_tool/ 2 | 3 | # IntelliJ related 4 | *.iml 5 | .idea/ 6 | 7 | pubspec_overrides.yaml -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023-2024 LiJianying 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-ZH.md: -------------------------------------------------------------------------------- 1 | > **🚀 快速发布您的应用**: 试试 [Fastforge](https://fastforge.dev) - 构建、打包和分发您的 Flutter 应用最简单的方式。 2 | 3 | # shortcut_menu_extender 4 | 5 | [![pub version][pub-image]][pub-url] [![][discord-image]][discord-url] ![][visits-count-image] 6 | 7 | [pub-image]: https://img.shields.io/pub/v/shortcut_menu_extender.svg 8 | [pub-url]: https://pub.dev/packages/shortcut_menu_extender 9 | [discord-image]: https://img.shields.io/discord/884679008049037342.svg 10 | [discord-url]: https://discord.gg/zPa6EZ2jqb 11 | [visits-count-image]: https://img.shields.io/badge/dynamic/json?label=Visits%20Count&query=value&url=https://api.countapi.xyz/hit/leanflutter.shortcut_menu_extender/visits 12 | 13 | 这个插件允许 Flutter 应用扩展全局快捷菜单。 14 | 15 | --- 16 | 17 | [English](./README.md) | 简体中文 18 | 19 | --- 20 | 21 | 22 | 23 | 24 | - [shortcut_menu_extender](#shortcut_menu_extender) 25 | - [平台支持](#平台支持) 26 | - [快速开始](#快速开始) 27 | - [安装](#安装) 28 | - [用法](#用法) 29 | - [Windows](#windows) 30 | - [注册/取消注册](#注册取消注册) 31 | - [监听事件](#监听事件) 32 | - [谁在用使用它?](#谁在用使用它) 33 | - [赞助者](#赞助者) 34 | - [许可证](#许可证) 35 | 36 | 37 | 38 | ## 平台支持 39 | 40 | | Linux | macOS | Windows | 41 | | :---: | :---: | :-----: | 42 | | ➖ | ➖ | ✔️ | 43 | 44 | ## 快速开始 45 | 46 | ### 安装 47 | 48 | 将此添加到你的软件包的 pubspec.yaml 文件: 49 | 50 | ```yaml 51 | dependencies: 52 | shortcut_menu_extender: ^0.1.1 53 | ``` 54 | 55 | ### 用法 56 | 57 | ##### Windows 58 | 59 | 更改文件 `windows/runner/main.cpp` 如下: 60 | 61 | ```diff 62 | #include 63 | #include 64 | #include 65 | 66 | #include "flutter_window.h" 67 | #include "utils.h" 68 | 69 | +#include 70 | 71 | int APIENTRY wWinMain(_In_ HINSTANCE instance, 72 | _In_opt_ HINSTANCE prev, 73 | _In_ wchar_t* command_line, 74 | _In_ int show_command) { 75 | + HANDLE instance_mutex = 76 | + CreateMutex(NULL, TRUE, L"shortcut_menu_extender_example"); 77 | + if (GetLastError() == ERROR_ALREADY_EXISTS && 78 | + !ShouldHandleByShortcutMenuExtenderCommand()) { 79 | + HWND hwnd = ::FindWindow(L"FLUTTER_RUNNER_WIN32_WINDOW", 80 | + L"shortcut_menu_extender_example"); 81 | + if (hwnd != NULL && ShouldHandleByShortcutMenuExtender()) { 82 | + DispatchToShortcutMenuExtender(hwnd); 83 | + } 84 | + CloseHandle(instance_mutex); 85 | + return EXIT_SUCCESS; 86 | + } 87 | 88 | // Attach to console when present (e.g., 'flutter run') or create a 89 | // new console when running with a debugger. 90 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 91 | CreateAndAttachConsole(); 92 | } 93 | 94 | // Initialize COM, so that it is available for use in the library and/or 95 | // plugins. 96 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 97 | 98 | flutter::DartProject project(L"data"); 99 | 100 | std::vector command_line_arguments = GetCommandLineArguments(); 101 | 102 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 103 | 104 | FlutterWindow window(project); 105 | Win32Window::Point origin(10, 10); 106 | Win32Window::Size size(1280, 720); 107 | if (!window.Create(L"shortcut_menu_extender_example", origin, size)) { 108 | return EXIT_FAILURE; 109 | } 110 | window.SetQuitOnClose(true); 111 | 112 | ::MSG msg; 113 | while (::GetMessage(&msg, nullptr, 0, 0)) { 114 | ::TranslateMessage(&msg); 115 | ::DispatchMessage(&msg); 116 | } 117 | 118 | ::CoUninitialize(); 119 | return EXIT_SUCCESS; 120 | } 121 | ``` 122 | 123 | ```dart 124 | import 'package:shortcut_menu_extender/shortcut_menu_extender.dart'; 125 | 126 | void main() async { 127 | // 必须加上这一行。 128 | WidgetsFlutterBinding.ensureInitialized(); 129 | 130 | if (shortcutMenuExtenderCommand.runIfNeeded(args)) exit(0); 131 | 132 | runApp(MyApp()); 133 | } 134 | ``` 135 | 136 | ### 注册/取消注册 137 | 138 | ```dart 139 | shortcutMenuExtender.register( 140 | 'MyFlutterApp', 141 | name: 'Open With MyFlutterApp', 142 | executable: Platform.resolvedExecutable, 143 | useDefaultIcon: true, 144 | ); 145 | 146 | shortcutMenuExtender.unregister( 147 | 'MyFlutterApp', 148 | ); 149 | ``` 150 | 151 | ### 监听事件 152 | 153 | ```dart 154 | class HomePage extends StatefulWidget { 155 | const HomePage({Key? key}) : super(key: key); 156 | 157 | @override 158 | _HomePageState createState() => _HomePageState(); 159 | } 160 | 161 | class _HomePageState extends State with ShortcutMenuListener { 162 | @override 163 | void initState() { 164 | shortcutMenuExtender.addListener(this); 165 | super.initState(); 166 | } 167 | 168 | @override 169 | void dispose() { 170 | shortcutMenuExtender.removeListener(this); 171 | super.dispose(); 172 | } 173 | 174 | @override 175 | Widget build(BuildContext context) { 176 | // ... 177 | } 178 | 179 | @override 180 | void onShortcutMenuClicked(String key, String path) { 181 | print('onShortcutMenuClicked: $key, $path'); 182 | } 183 | } 184 | ``` 185 | 186 | > 请看这个插件的示例应用,以了解完整的例子。 187 | 188 | ## 赞助者 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 |
cmlanche
cmlanche
197 | 198 | ## 许可证 199 | 200 | [MIT](./LICENSE) 201 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | > **🚀 Ship Your App Faster**: Try [Fastforge](https://fastforge.dev) - The simplest way to build, package and distribute your Flutter apps. 2 | 3 | # shortcut_menu_extender 4 | 5 | [![pub version][pub-image]][pub-url] [![][discord-image]][discord-url] ![][visits-count-image] 6 | 7 | [pub-image]: https://img.shields.io/pub/v/shortcut_menu_extender.svg 8 | [pub-url]: https://pub.dev/packages/shortcut_menu_extender 9 | [discord-image]: https://img.shields.io/discord/884679008049037342.svg 10 | [discord-url]: https://discord.gg/zPa6EZ2jqb 11 | [visits-count-image]: https://img.shields.io/badge/dynamic/json?label=Visits%20Count&query=value&url=https://api.countapi.xyz/hit/leanflutter.shortcut_menu_extender/visits 12 | 13 | This plugin allows Flutter apps to Extending global shortcut menus. 14 | 15 | --- 16 | 17 | English | [简体中文](./README-ZH.md) 18 | 19 | --- 20 | 21 | 22 | 23 | 24 | - [shortcut_menu_extender](#shortcut_menu_extender) 25 | - [Platform Support](#platform-support) 26 | - [Quick Start](#quick-start) 27 | - [Installation](#installation) 28 | - [Usage](#usage) 29 | - [Windows](#windows) 30 | - [Register/Unregister](#registerunregister) 31 | - [Listening events](#listening-events) 32 | - [Who's using it?](#whos-using-it) 33 | - [Sponsors](#sponsors) 34 | - [License](#license) 35 | 36 | 37 | 38 | ## Platform Support 39 | 40 | | Linux | macOS | Windows | 41 | | :---: | :---: | :-----: | 42 | | ➖ | ➖ | ✔️ | 43 | 44 | ## Quick Start 45 | 46 | ### Installation 47 | 48 | Add this to your package's pubspec.yaml file: 49 | 50 | ```yaml 51 | dependencies: 52 | shortcut_menu_extender: ^0.1.1 53 | ``` 54 | 55 | ### Usage 56 | 57 | ##### Windows 58 | 59 | Change the file `windows/runner/main.cpp` as follows: 60 | 61 | ```diff 62 | #include 63 | #include 64 | #include 65 | 66 | #include "flutter_window.h" 67 | #include "utils.h" 68 | 69 | +#include 70 | 71 | int APIENTRY wWinMain(_In_ HINSTANCE instance, 72 | _In_opt_ HINSTANCE prev, 73 | _In_ wchar_t* command_line, 74 | _In_ int show_command) { 75 | + HANDLE instance_mutex = 76 | + CreateMutex(NULL, TRUE, L"shortcut_menu_extender_example"); 77 | + if (GetLastError() == ERROR_ALREADY_EXISTS && 78 | + !ShouldHandleByShortcutMenuExtenderCommand()) { 79 | + HWND hwnd = ::FindWindow(L"FLUTTER_RUNNER_WIN32_WINDOW", 80 | + L"shortcut_menu_extender_example"); 81 | + if (hwnd != NULL && ShouldHandleByShortcutMenuExtender()) { 82 | + DispatchToShortcutMenuExtender(hwnd); 83 | + } 84 | + CloseHandle(instance_mutex); 85 | + return EXIT_SUCCESS; 86 | + } 87 | 88 | // Attach to console when present (e.g., 'flutter run') or create a 89 | // new console when running with a debugger. 90 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 91 | CreateAndAttachConsole(); 92 | } 93 | 94 | // Initialize COM, so that it is available for use in the library and/or 95 | // plugins. 96 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 97 | 98 | flutter::DartProject project(L"data"); 99 | 100 | std::vector command_line_arguments = GetCommandLineArguments(); 101 | 102 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 103 | 104 | FlutterWindow window(project); 105 | Win32Window::Point origin(10, 10); 106 | Win32Window::Size size(1280, 720); 107 | if (!window.Create(L"shortcut_menu_extender_example", origin, size)) { 108 | return EXIT_FAILURE; 109 | } 110 | window.SetQuitOnClose(true); 111 | 112 | ::MSG msg; 113 | while (::GetMessage(&msg, nullptr, 0, 0)) { 114 | ::TranslateMessage(&msg); 115 | ::DispatchMessage(&msg); 116 | } 117 | 118 | ::CoUninitialize(); 119 | return EXIT_SUCCESS; 120 | } 121 | ``` 122 | 123 | ```dart 124 | import 'package:shortcut_menu_extender/shortcut_menu_extender.dart'; 125 | 126 | void main() async { 127 | // Must add this line. 128 | WidgetsFlutterBinding.ensureInitialized(); 129 | 130 | if (shortcutMenuExtenderCommand.runIfNeeded(args)) exit(0); 131 | 132 | runApp(MyApp()); 133 | } 134 | ``` 135 | 136 | ### Register/Unregister 137 | 138 | ```dart 139 | shortcutMenuExtender.register( 140 | 'MyFlutterApp', 141 | name: 'Open With MyFlutterApp', 142 | executable: Platform.resolvedExecutable, 143 | useDefaultIcon: true, 144 | ); 145 | 146 | shortcutMenuExtender.unregister( 147 | 'MyFlutterApp', 148 | ); 149 | ``` 150 | 151 | ### Listening events 152 | 153 | ```dart 154 | class HomePage extends StatefulWidget { 155 | const HomePage({Key? key}) : super(key: key); 156 | 157 | @override 158 | _HomePageState createState() => _HomePageState(); 159 | } 160 | 161 | class _HomePageState extends State with ShortcutMenuListener { 162 | @override 163 | void initState() { 164 | shortcutMenuExtender.addListener(this); 165 | super.initState(); 166 | } 167 | 168 | @override 169 | void dispose() { 170 | shortcutMenuExtender.removeListener(this); 171 | super.dispose(); 172 | } 173 | 174 | @override 175 | Widget build(BuildContext context) { 176 | // ... 177 | } 178 | 179 | @override 180 | void onShortcutMenuClicked(String key, String path) { 181 | print('onShortcutMenuClicked: $key, $path'); 182 | } 183 | } 184 | ``` 185 | 186 | > Please see the example app of this plugin for a full example. 187 | 188 | ## Sponsors 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 |
cmlanche
cmlanche
197 | 198 | ## License 199 | 200 | [MIT](./LICENSE) 201 | -------------------------------------------------------------------------------- /melos.yaml: -------------------------------------------------------------------------------- 1 | name: shortcut_menu_extender 2 | repository: https://github.com/leanflutter/shortcut_menu_extender 3 | 4 | packages: 5 | - examples/** 6 | - packages/** 7 | 8 | command: 9 | bootstrap: 10 | # Uses the pubspec_overrides.yaml instead of having Melos modifying the lock file. 11 | usePubspecOverrides: true 12 | 13 | scripts: 14 | analyze: 15 | exec: flutter analyze --fatal-infos 16 | description: Run `flutter analyze` for all packages. 17 | 18 | test: 19 | exec: flutter test 20 | description: Run `flutter test` for a specific package. 21 | packageFilters: 22 | dirExists: 23 | - test 24 | 25 | format: 26 | exec: dart format . --fix 27 | description: Run `dart format` for all packages. 28 | 29 | format-check: 30 | exec: dart format . --fix --set-exit-if-changed 31 | description: Run `dart format` checks for all packages. 32 | 33 | fix: 34 | exec: dart fix . --apply 35 | description: Run `dart fix` for all packages. 36 | 37 | dependency_validator: 38 | exec: flutter pub run dependency_validator 39 | packageFilters: 40 | dependsOn: 41 | - dependency_validator 42 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. 26 | /pubspec.lock 27 | **/doc/api/ 28 | .dart_tool/ 29 | build/ 30 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/.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: "db7ef5bf9f59442b0e200a90587e8fa5e0c6336a" 8 | channel: "stable" 9 | 10 | project_type: plugin 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a 17 | base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a 18 | 19 | # User provided section 20 | 21 | # List of Local paths (relative to this file) that should be 22 | # ignored by the migrate tool. 23 | # 24 | # Files that are not part of the templates will be ignored by default. 25 | unmanaged_files: 26 | - 'lib/main.dart' 27 | - 'ios/Runner.xcodeproj/project.pbxproj' 28 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.2.0 2 | 3 | * chore: Update to new version of shortcut_menu_extender_platform_interface 4 | * Bump win32 to 5.15.0 & win32_registry to 2.1.0 5 | 6 | ## 0.1.1 7 | 8 | * chore: Add dartdoc comments to public API 9 | 10 | ## 0.1.0 11 | 12 | * First release. 13 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023-2024 LiJianying 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. -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/README-ZH.md: -------------------------------------------------------------------------------- 1 | ../../README-ZH.md -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/README.md: -------------------------------------------------------------------------------- 1 | ../../README.md -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:mostly_reasonable_lints/flutter.yaml 2 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | **/doc/api/ 26 | **/ios/Flutter/.last_build_id 27 | .dart_tool/ 28 | .flutter-plugins 29 | .flutter-plugins-dependencies 30 | .pub-cache/ 31 | .pub/ 32 | /build/ 33 | 34 | # Symbolication related 35 | app.*.symbols 36 | 37 | # Obfuscation related 38 | app.*.map.json 39 | 40 | # Android Studio will place build artifacts here 41 | /android/app/debug 42 | /android/app/profile 43 | /android/app/release 44 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/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: "db7ef5bf9f59442b0e200a90587e8fa5e0c6336a" 8 | channel: "stable" 9 | 10 | project_type: app 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a 17 | base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a 18 | - platform: windows 19 | create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a 20 | base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a 21 | 22 | # User provided section 23 | 24 | # List of Local paths (relative to this file) that should be 25 | # ignored by the migrate tool. 26 | # 27 | # Files that are not part of the templates will be ignored by default. 28 | unmanaged_files: 29 | - 'lib/main.dart' 30 | - 'ios/Runner.xcodeproj/project.pbxproj' 31 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/example/README.md: -------------------------------------------------------------------------------- 1 | # shortcut_menu_extender_example 2 | 3 | Demonstrates how to use the shortcut_menu_extender plugin. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) 13 | 14 | For help getting started with Flutter development, view the 15 | [online documentation](https://docs.flutter.dev/), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/example/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:mostly_reasonable_lints/flutter.yaml 2 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/example/integration_test/plugin_integration_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter integration test. 2 | // 3 | // Since integration tests run in a full Flutter application, they can interact 4 | // with the host side of a plugin implementation, unlike Dart unit tests. 5 | // 6 | // For more information about Flutter integration tests, please see 7 | // https://docs.flutter.dev/cookbook/testing/integration/introduction 8 | 9 | import 'package:flutter_test/flutter_test.dart'; 10 | import 'package:integration_test/integration_test.dart'; 11 | 12 | import 'package:shortcut_menu_extender/shortcut_menu_extender.dart'; 13 | 14 | void main() { 15 | IntegrationTestWidgetsFlutterBinding.ensureInitialized(); 16 | 17 | testWidgets('getPlatformVersion test', (WidgetTester tester) async { 18 | final ShortcutMenuExtender plugin = ShortcutMenuExtender(); 19 | final String? version = await plugin.getPlatformVersion(); 20 | // The version string depends on the host platform running the test, so 21 | // just assert that some non-empty string is returned. 22 | expect(version?.isNotEmpty, true); 23 | }); 24 | } 25 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:io'; 3 | 4 | import 'package:flutter/foundation.dart'; 5 | import 'package:flutter/material.dart'; 6 | import 'package:flutter/services.dart'; 7 | import 'package:shortcut_menu_extender/shortcut_menu_extender.dart'; 8 | 9 | const _kShortcutMenuKeyMyFlutterApp = 'MyFlutterApp'; 10 | const _kShortcutMenuKeyMyFlutterApp2 = 'MyFlutterApp2'; 11 | 12 | void main(List args) { 13 | WidgetsFlutterBinding.ensureInitialized(); 14 | 15 | if (shortcutMenuExtenderCommand.runIfNeeded(args)) exit(0); 16 | runApp(const MyApp()); 17 | } 18 | 19 | class MyApp extends StatefulWidget { 20 | const MyApp({super.key}); 21 | 22 | @override 23 | State createState() => _MyAppState(); 24 | } 25 | 26 | class _MyAppState extends State with ShortcutMenuListener { 27 | String _platformVersion = 'Unknown'; 28 | final _shortcutMenuExtenderPlugin = ShortcutMenuExtender(); 29 | 30 | final List _entities = []; 31 | 32 | @override 33 | void initState() { 34 | shortcutMenuExtender.addListener(this); 35 | super.initState(); 36 | initPlatformState(); 37 | } 38 | 39 | @override 40 | void dispose() { 41 | shortcutMenuExtender.removeListener(this); 42 | super.dispose(); 43 | } 44 | 45 | // Platform messages are asynchronous, so we initialize in an async method. 46 | Future initPlatformState() async { 47 | String platformVersion; 48 | // Platform messages may fail, so we use a try/catch PlatformException. 49 | // We also handle the message potentially returning null. 50 | try { 51 | platformVersion = 52 | await _shortcutMenuExtenderPlugin.getPlatformVersion() ?? 53 | 'Unknown platform version'; 54 | } on PlatformException { 55 | platformVersion = 'Failed to get platform version.'; 56 | } 57 | 58 | // If the widget was removed from the tree while the asynchronous platform 59 | // message was in flight, we want to discard the reply rather than calling 60 | // setState to update our non-existent appearance. 61 | if (!mounted) return; 62 | 63 | setState(() { 64 | _platformVersion = platformVersion; 65 | }); 66 | } 67 | 68 | @override 69 | Widget build(BuildContext context) { 70 | return MaterialApp( 71 | home: Scaffold( 72 | appBar: AppBar( 73 | title: const Text('Plugin example app'), 74 | ), 75 | body: Column( 76 | children: [ 77 | Text('Running on: $_platformVersion\n'), 78 | ElevatedButton( 79 | onPressed: () { 80 | shortcutMenuExtender.register( 81 | _kShortcutMenuKeyMyFlutterApp, 82 | name: 'Open with MyFlutterApp', 83 | executable: Platform.resolvedExecutable, 84 | useDefaultIcon: true, 85 | ); 86 | }, 87 | child: const Text('register MyFlutterApp'), 88 | ), 89 | ElevatedButton( 90 | onPressed: () { 91 | shortcutMenuExtender.unregister( 92 | _kShortcutMenuKeyMyFlutterApp, 93 | ); 94 | }, 95 | child: const Text('unregister MyFlutterApp'), 96 | ), 97 | ElevatedButton( 98 | onPressed: () { 99 | shortcutMenuExtender.register( 100 | _kShortcutMenuKeyMyFlutterApp2, 101 | name: '用我的FlutterApp打开', 102 | executable: Platform.resolvedExecutable, 103 | useDefaultIcon: false, 104 | ); 105 | }, 106 | child: const Text('register 我的MyFlutterApp2'), 107 | ), 108 | ElevatedButton( 109 | onPressed: () { 110 | shortcutMenuExtender.unregister( 111 | _kShortcutMenuKeyMyFlutterApp2, 112 | ); 113 | }, 114 | child: const Text('unregister 我的FlutterApp2'), 115 | ), 116 | Expanded( 117 | child: ListView( 118 | children: [ 119 | for (final entity in _entities) 120 | ListTile( 121 | title: Text(entity.statSync().type.toString()), 122 | subtitle: Text(entity.path), 123 | ), 124 | ], 125 | ), 126 | ), 127 | ], 128 | ), 129 | ), 130 | ); 131 | } 132 | 133 | @override 134 | void onShortcutMenuClicked(String key, String path) { 135 | if (key == _kShortcutMenuKeyMyFlutterApp) { 136 | final type = FileSystemEntity.typeSync(path); 137 | if (type == FileSystemEntityType.file) { 138 | _entities.add(File(path)); 139 | } else if (type == FileSystemEntityType.directory) { 140 | _entities.add(Directory(path)); 141 | } 142 | setState(() {}); 143 | } else if (key == _kShortcutMenuKeyMyFlutterApp2) { 144 | if (kDebugMode) { 145 | print('key: $key, path: $path'); 146 | } 147 | } 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/example/pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | args: 5 | dependency: transitive 6 | description: 7 | name: args 8 | sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 9 | url: "https://pub.dev" 10 | source: hosted 11 | version: "2.4.2" 12 | async: 13 | dependency: transitive 14 | description: 15 | name: async 16 | sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63 17 | url: "https://pub.dev" 18 | source: hosted 19 | version: "2.12.0" 20 | boolean_selector: 21 | dependency: transitive 22 | description: 23 | name: boolean_selector 24 | sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" 25 | url: "https://pub.dev" 26 | source: hosted 27 | version: "2.1.2" 28 | characters: 29 | dependency: transitive 30 | description: 31 | name: characters 32 | sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 33 | url: "https://pub.dev" 34 | source: hosted 35 | version: "1.4.0" 36 | clock: 37 | dependency: transitive 38 | description: 39 | name: clock 40 | sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b 41 | url: "https://pub.dev" 42 | source: hosted 43 | version: "1.1.2" 44 | collection: 45 | dependency: transitive 46 | description: 47 | name: collection 48 | sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" 49 | url: "https://pub.dev" 50 | source: hosted 51 | version: "1.19.1" 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 | ffi: 61 | dependency: transitive 62 | description: 63 | name: ffi 64 | sha256: "289279317b4b16eb2bb7e271abccd4bf84ec9bdcbe999e278a94b804f5630418" 65 | url: "https://pub.dev" 66 | source: hosted 67 | version: "2.1.4" 68 | file: 69 | dependency: transitive 70 | description: 71 | name: file 72 | sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4 73 | url: "https://pub.dev" 74 | source: hosted 75 | version: "7.0.1" 76 | flutter: 77 | dependency: "direct main" 78 | description: flutter 79 | source: sdk 80 | version: "0.0.0" 81 | flutter_driver: 82 | dependency: transitive 83 | description: flutter 84 | source: sdk 85 | version: "0.0.0" 86 | flutter_test: 87 | dependency: "direct dev" 88 | description: flutter 89 | source: sdk 90 | version: "0.0.0" 91 | fuchsia_remote_debug_protocol: 92 | dependency: transitive 93 | description: flutter 94 | source: sdk 95 | version: "0.0.0" 96 | integration_test: 97 | dependency: "direct dev" 98 | description: flutter 99 | source: sdk 100 | version: "0.0.0" 101 | leak_tracker: 102 | dependency: transitive 103 | description: 104 | name: leak_tracker 105 | sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec 106 | url: "https://pub.dev" 107 | source: hosted 108 | version: "10.0.8" 109 | leak_tracker_flutter_testing: 110 | dependency: transitive 111 | description: 112 | name: leak_tracker_flutter_testing 113 | sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573 114 | url: "https://pub.dev" 115 | source: hosted 116 | version: "3.0.9" 117 | leak_tracker_testing: 118 | dependency: transitive 119 | description: 120 | name: leak_tracker_testing 121 | sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" 122 | url: "https://pub.dev" 123 | source: hosted 124 | version: "3.0.1" 125 | lints: 126 | dependency: transitive 127 | description: 128 | name: lints 129 | sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290 130 | url: "https://pub.dev" 131 | source: hosted 132 | version: "3.0.0" 133 | matcher: 134 | dependency: transitive 135 | description: 136 | name: matcher 137 | sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 138 | url: "https://pub.dev" 139 | source: hosted 140 | version: "0.12.17" 141 | material_color_utilities: 142 | dependency: transitive 143 | description: 144 | name: material_color_utilities 145 | sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec 146 | url: "https://pub.dev" 147 | source: hosted 148 | version: "0.11.1" 149 | meta: 150 | dependency: transitive 151 | description: 152 | name: meta 153 | sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c 154 | url: "https://pub.dev" 155 | source: hosted 156 | version: "1.16.0" 157 | mostly_reasonable_lints: 158 | dependency: "direct dev" 159 | description: 160 | name: mostly_reasonable_lints 161 | sha256: c61cc6b211f54188eef15e0ad7c9b00e8c001478ac253a52036ef7391b532b7c 162 | url: "https://pub.dev" 163 | source: hosted 164 | version: "0.1.1" 165 | path: 166 | dependency: transitive 167 | description: 168 | name: path 169 | sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" 170 | url: "https://pub.dev" 171 | source: hosted 172 | version: "1.9.1" 173 | platform: 174 | dependency: transitive 175 | description: 176 | name: platform 177 | sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984" 178 | url: "https://pub.dev" 179 | source: hosted 180 | version: "3.1.6" 181 | plugin_platform_interface: 182 | dependency: transitive 183 | description: 184 | name: plugin_platform_interface 185 | sha256: f4f88d4a900933e7267e2b353594774fc0d07fb072b47eedcd5b54e1ea3269f8 186 | url: "https://pub.dev" 187 | source: hosted 188 | version: "2.1.7" 189 | process: 190 | dependency: transitive 191 | description: 192 | name: process 193 | sha256: "107d8be718f120bbba9dcd1e95e3bd325b1b4a4f07db64154635ba03f2567a0d" 194 | url: "https://pub.dev" 195 | source: hosted 196 | version: "5.0.3" 197 | shortcut_menu_extender: 198 | dependency: "direct main" 199 | description: 200 | path: ".." 201 | relative: true 202 | source: path 203 | version: "0.2.0" 204 | shortcut_menu_extender_platform_interface: 205 | dependency: "direct overridden" 206 | description: 207 | path: "../../shortcut_menu_extender_platform_interface" 208 | relative: true 209 | source: path 210 | version: "0.2.0" 211 | shortcut_menu_extender_windows: 212 | dependency: "direct overridden" 213 | description: 214 | path: "../../shortcut_menu_extender_windows" 215 | relative: true 216 | source: path 217 | version: "0.2.0" 218 | sky_engine: 219 | dependency: transitive 220 | description: flutter 221 | source: sdk 222 | version: "0.0.0" 223 | source_span: 224 | dependency: transitive 225 | description: 226 | name: source_span 227 | sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c" 228 | url: "https://pub.dev" 229 | source: hosted 230 | version: "1.10.1" 231 | stack_trace: 232 | dependency: transitive 233 | description: 234 | name: stack_trace 235 | sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" 236 | url: "https://pub.dev" 237 | source: hosted 238 | version: "1.12.1" 239 | stream_channel: 240 | dependency: transitive 241 | description: 242 | name: stream_channel 243 | sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" 244 | url: "https://pub.dev" 245 | source: hosted 246 | version: "2.1.4" 247 | string_scanner: 248 | dependency: transitive 249 | description: 250 | name: string_scanner 251 | sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" 252 | url: "https://pub.dev" 253 | source: hosted 254 | version: "1.4.1" 255 | sync_http: 256 | dependency: transitive 257 | description: 258 | name: sync_http 259 | sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961" 260 | url: "https://pub.dev" 261 | source: hosted 262 | version: "0.3.1" 263 | term_glyph: 264 | dependency: transitive 265 | description: 266 | name: term_glyph 267 | sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" 268 | url: "https://pub.dev" 269 | source: hosted 270 | version: "1.2.2" 271 | test_api: 272 | dependency: transitive 273 | description: 274 | name: test_api 275 | sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd 276 | url: "https://pub.dev" 277 | source: hosted 278 | version: "0.7.4" 279 | vector_math: 280 | dependency: transitive 281 | description: 282 | name: vector_math 283 | sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" 284 | url: "https://pub.dev" 285 | source: hosted 286 | version: "2.1.4" 287 | vm_service: 288 | dependency: transitive 289 | description: 290 | name: vm_service 291 | sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14" 292 | url: "https://pub.dev" 293 | source: hosted 294 | version: "14.3.1" 295 | webdriver: 296 | dependency: transitive 297 | description: 298 | name: webdriver 299 | sha256: "3d773670966f02a646319410766d3b5e1037efb7f07cc68f844d5e06cd4d61c8" 300 | url: "https://pub.dev" 301 | source: hosted 302 | version: "3.0.4" 303 | win32: 304 | dependency: transitive 305 | description: 306 | name: win32 307 | sha256: dc6ecaa00a7c708e5b4d10ee7bec8c270e9276dfcab1783f57e9962d7884305f 308 | url: "https://pub.dev" 309 | source: hosted 310 | version: "5.12.0" 311 | win32_registry: 312 | dependency: transitive 313 | description: 314 | name: win32_registry 315 | sha256: "6f1b564492d0147b330dd794fee8f512cec4977957f310f9951b5f9d83618dae" 316 | url: "https://pub.dev" 317 | source: hosted 318 | version: "2.1.0" 319 | sdks: 320 | dart: ">=3.7.0 <4.0.0" 321 | flutter: ">=3.18.0-18.0.pre.54" 322 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: shortcut_menu_extender_example 2 | description: "Demonstrates how to use the shortcut_menu_extender plugin." 3 | publish_to: "none" 4 | 5 | environment: 6 | sdk: ">=3.0.0 <4.0.0" 7 | 8 | dependencies: 9 | flutter: 10 | sdk: flutter 11 | shortcut_menu_extender: 12 | path: ../ 13 | 14 | dev_dependencies: 15 | flutter_test: 16 | sdk: flutter 17 | integration_test: 18 | sdk: flutter 19 | mostly_reasonable_lints: ^0.1.1 20 | 21 | flutter: 22 | uses-material-design: true 23 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/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 in the flutter_test package. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter_test/flutter_test.dart'; 10 | 11 | import 'package:shortcut_menu_extender_example/main.dart'; 12 | 13 | void main() { 14 | testWidgets('Verify Platform version', (WidgetTester tester) async { 15 | // Build our app and trigger a frame. 16 | await tester.pumpWidget(const MyApp()); 17 | 18 | // Verify that platform version is retrieved. 19 | expect( 20 | find.byWidgetPredicate( 21 | (Widget widget) => 22 | widget is Text && widget.data!.startsWith('Running on:'), 23 | ), 24 | findsOneWidget, 25 | ); 26 | }); 27 | } 28 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/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 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/example/windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.14) 3 | project(example LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "example") 8 | 9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 10 | # versions of CMake. 11 | cmake_policy(VERSION 3.14...3.25) 12 | 13 | # Define build configuration option. 14 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 15 | if(IS_MULTICONFIG) 16 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 17 | CACHE STRING "" FORCE) 18 | else() 19 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 20 | set(CMAKE_BUILD_TYPE "Debug" CACHE 21 | STRING "Flutter build mode" FORCE) 22 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 23 | "Debug" "Profile" "Release") 24 | endif() 25 | endif() 26 | # Define settings for the Profile build mode. 27 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 28 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 29 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 30 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 31 | 32 | # Use Unicode for all projects. 33 | add_definitions(-DUNICODE -D_UNICODE) 34 | 35 | # Compilation settings that should be applied to most targets. 36 | # 37 | # Be cautious about adding new options here, as plugins use this function by 38 | # default. In most cases, you should add new options to specific targets instead 39 | # of modifying this function. 40 | function(APPLY_STANDARD_SETTINGS TARGET) 41 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 42 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 43 | target_compile_options(${TARGET} PRIVATE /EHsc) 44 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 45 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 46 | endfunction() 47 | 48 | # Flutter library and tool build rules. 49 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 50 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 51 | 52 | # Application build; see runner/CMakeLists.txt. 53 | add_subdirectory("runner") 54 | 55 | 56 | # Generated plugin build rules, which manage building the plugins and adding 57 | # them to the application. 58 | include(flutter/generated_plugins.cmake) 59 | 60 | 61 | # === Installation === 62 | # Support files are copied into place next to the executable, so that it can 63 | # run in place. This is done instead of making a separate bundle (as on Linux) 64 | # so that building and running from within Visual Studio will work. 65 | set(BUILD_BUNDLE_DIR "$") 66 | # Make the "install" step default, as it's required to run. 67 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 68 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 69 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 70 | endif() 71 | 72 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 73 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 74 | 75 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 76 | COMPONENT Runtime) 77 | 78 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 79 | COMPONENT Runtime) 80 | 81 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 82 | COMPONENT Runtime) 83 | 84 | if(PLUGIN_BUNDLED_LIBRARIES) 85 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 86 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 87 | COMPONENT Runtime) 88 | endif() 89 | 90 | # Copy the native assets provided by the build.dart from all packages. 91 | set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") 92 | install(DIRECTORY "${NATIVE_ASSETS_DIR}" 93 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 94 | COMPONENT Runtime) 95 | 96 | # Fully re-copy the assets directory on each build to avoid having stale files 97 | # from a previous install. 98 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 99 | install(CODE " 100 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 101 | " COMPONENT Runtime) 102 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 103 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 104 | 105 | # Install the AOT library on non-Debug builds only. 106 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 107 | CONFIGURATIONS Profile;Release 108 | COMPONENT Runtime) 109 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/example/windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.14) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 12 | 13 | # Set fallback configurations for older versions of the flutter tool. 14 | if (NOT DEFINED FLUTTER_TARGET_PLATFORM) 15 | set(FLUTTER_TARGET_PLATFORM "windows-x64") 16 | endif() 17 | 18 | # === Flutter Library === 19 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 20 | 21 | # Published to parent scope for install step. 22 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 23 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 24 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 25 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 26 | 27 | list(APPEND FLUTTER_LIBRARY_HEADERS 28 | "flutter_export.h" 29 | "flutter_windows.h" 30 | "flutter_messenger.h" 31 | "flutter_plugin_registrar.h" 32 | "flutter_texture_registrar.h" 33 | ) 34 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 35 | add_library(flutter INTERFACE) 36 | target_include_directories(flutter INTERFACE 37 | "${EPHEMERAL_DIR}" 38 | ) 39 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 40 | add_dependencies(flutter flutter_assemble) 41 | 42 | # === Wrapper === 43 | list(APPEND CPP_WRAPPER_SOURCES_CORE 44 | "core_implementations.cc" 45 | "standard_codec.cc" 46 | ) 47 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 48 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 49 | "plugin_registrar.cc" 50 | ) 51 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 52 | list(APPEND CPP_WRAPPER_SOURCES_APP 53 | "flutter_engine.cc" 54 | "flutter_view_controller.cc" 55 | ) 56 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 57 | 58 | # Wrapper sources needed for a plugin. 59 | add_library(flutter_wrapper_plugin STATIC 60 | ${CPP_WRAPPER_SOURCES_CORE} 61 | ${CPP_WRAPPER_SOURCES_PLUGIN} 62 | ) 63 | apply_standard_settings(flutter_wrapper_plugin) 64 | set_target_properties(flutter_wrapper_plugin PROPERTIES 65 | POSITION_INDEPENDENT_CODE ON) 66 | set_target_properties(flutter_wrapper_plugin PROPERTIES 67 | CXX_VISIBILITY_PRESET hidden) 68 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 69 | target_include_directories(flutter_wrapper_plugin PUBLIC 70 | "${WRAPPER_ROOT}/include" 71 | ) 72 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 73 | 74 | # Wrapper sources needed for the runner. 75 | add_library(flutter_wrapper_app STATIC 76 | ${CPP_WRAPPER_SOURCES_CORE} 77 | ${CPP_WRAPPER_SOURCES_APP} 78 | ) 79 | apply_standard_settings(flutter_wrapper_app) 80 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 81 | target_include_directories(flutter_wrapper_app PUBLIC 82 | "${WRAPPER_ROOT}/include" 83 | ) 84 | add_dependencies(flutter_wrapper_app flutter_assemble) 85 | 86 | # === Flutter tool backend === 87 | # _phony_ is a non-existent file to force this command to run every time, 88 | # since currently there's no way to get a full input/output list from the 89 | # flutter tool. 90 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 91 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 92 | add_custom_command( 93 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 94 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 95 | ${CPP_WRAPPER_SOURCES_APP} 96 | ${PHONY_OUTPUT} 97 | COMMAND ${CMAKE_COMMAND} -E env 98 | ${FLUTTER_TOOL_ENVIRONMENT} 99 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 100 | ${FLUTTER_TARGET_PLATFORM} $ 101 | VERBATIM 102 | ) 103 | add_custom_target(flutter_assemble DEPENDS 104 | "${FLUTTER_LIBRARY}" 105 | ${FLUTTER_LIBRARY_HEADERS} 106 | ${CPP_WRAPPER_SOURCES_CORE} 107 | ${CPP_WRAPPER_SOURCES_PLUGIN} 108 | ${CPP_WRAPPER_SOURCES_APP} 109 | ) 110 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/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 | ShortcutMenuExtenderWindowsPluginCApiRegisterWithRegistrar( 13 | registry->GetRegistrarForPlugin("ShortcutMenuExtenderWindowsPluginCApi")); 14 | } 15 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/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 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/example/windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | shortcut_menu_extender_windows 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 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/example/windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} WIN32 10 | "flutter_window.cpp" 11 | "main.cpp" 12 | "utils.cpp" 13 | "win32_window.cpp" 14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 15 | "Runner.rc" 16 | "runner.exe.manifest" 17 | ) 18 | 19 | # Apply the standard set of build settings. This can be removed for applications 20 | # that need different build settings. 21 | apply_standard_settings(${BINARY_NAME}) 22 | 23 | # Add preprocessor definitions for the build version. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") 25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") 26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") 27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") 28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") 29 | 30 | # Disable Windows macros that collide with C++ standard library functions. 31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 32 | 33 | # Add dependency libraries and include directories. Add any application-specific 34 | # dependencies here. 35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 36 | target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") 37 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 38 | 39 | # Run the Flutter tool portions of the build. This must not be removed. 40 | add_dependencies(${BINARY_NAME} flutter_assemble) 41 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/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", "com.example" "\0" 93 | VALUE "FileDescription", "example" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "example" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2023 com.example. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "example.exe" "\0" 98 | VALUE "ProductName", "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 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/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(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | 30 | flutter_controller_->engine()->SetNextFrameCallback([&]() { 31 | this->Show(); 32 | }); 33 | 34 | // Flutter can complete the first frame before the "show window" callback is 35 | // registered. The following call ensures a frame is pending to ensure the 36 | // window is shown. It is a no-op if the first frame hasn't completed yet. 37 | flutter_controller_->ForceRedraw(); 38 | 39 | return true; 40 | } 41 | 42 | void FlutterWindow::OnDestroy() { 43 | if (flutter_controller_) { 44 | flutter_controller_ = nullptr; 45 | } 46 | 47 | Win32Window::OnDestroy(); 48 | } 49 | 50 | LRESULT 51 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 52 | WPARAM const wparam, 53 | LPARAM const lparam) noexcept { 54 | // Give Flutter, including plugins, an opportunity to handle window messages. 55 | if (flutter_controller_) { 56 | std::optional result = 57 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 58 | lparam); 59 | if (result) { 60 | return *result; 61 | } 62 | } 63 | 64 | switch (message) { 65 | case WM_FONTCHANGE: 66 | flutter_controller_->engine()->ReloadSystemFonts(); 67 | break; 68 | } 69 | 70 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 71 | } 72 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/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 "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/example/windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | #include 9 | 10 | int APIENTRY wWinMain(_In_ HINSTANCE instance, 11 | _In_opt_ HINSTANCE prev, 12 | _In_ wchar_t* command_line, 13 | _In_ int show_command) { 14 | HANDLE instance_mutex = 15 | CreateMutex(NULL, TRUE, L"shortcut_menu_extender_example"); 16 | if (GetLastError() == ERROR_ALREADY_EXISTS && 17 | !ShouldHandleByShortcutMenuExtenderCommand()) { 18 | HWND hwnd = ::FindWindow(L"FLUTTER_RUNNER_WIN32_WINDOW", 19 | L"shortcut_menu_extender_example"); 20 | if (hwnd != NULL && ShouldHandleByShortcutMenuExtender()) { 21 | DispatchToShortcutMenuExtender(hwnd); 22 | } 23 | CloseHandle(instance_mutex); 24 | return EXIT_SUCCESS; 25 | } 26 | 27 | // Attach to console when present (e.g., 'flutter run') or create a 28 | // new console when running with a debugger. 29 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 30 | CreateAndAttachConsole(); 31 | } 32 | 33 | // Initialize COM, so that it is available for use in the library and/or 34 | // plugins. 35 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 36 | 37 | flutter::DartProject project(L"data"); 38 | 39 | std::vector command_line_arguments = GetCommandLineArguments(); 40 | 41 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 42 | 43 | FlutterWindow window(project); 44 | Win32Window::Point origin(10, 10); 45 | Win32Window::Size size(1280, 720); 46 | if (!window.Create(L"shortcut_menu_extender_example", origin, size)) { 47 | return EXIT_FAILURE; 48 | } 49 | window.SetQuitOnClose(true); 50 | 51 | ::MSG msg; 52 | while (::GetMessage(&msg, nullptr, 0, 0)) { 53 | ::TranslateMessage(&msg); 54 | ::DispatchMessage(&msg); 55 | } 56 | 57 | ::CoUninitialize(); 58 | return EXIT_SUCCESS; 59 | } 60 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/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 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/example/windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leanflutter/shortcut_menu_extender/421fb0d29f38466c308b94e6aecb4c5ded6df139/packages/shortcut_menu_extender/example/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/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 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/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 | -1; // remove the trailing null character 52 | int input_length = (int)wcslen(utf16_string); 53 | std::string utf8_string; 54 | if (target_length <= 0 || target_length > utf8_string.max_size()) { 55 | return utf8_string; 56 | } 57 | utf8_string.resize(target_length); 58 | int converted_length = ::WideCharToMultiByte( 59 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 60 | input_length, utf8_string.data(), target_length, nullptr, nullptr); 61 | if (converted_length == 0) { 62 | return std::string(); 63 | } 64 | return utf8_string; 65 | } 66 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/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 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/example/windows/runner/win32_window.cpp: -------------------------------------------------------------------------------- 1 | #include "win32_window.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "resource.h" 7 | 8 | namespace { 9 | 10 | /// Window attribute that enables dark mode window decorations. 11 | /// 12 | /// Redefined in case the developer's machine has a Windows SDK older than 13 | /// version 10.0.22000.0. 14 | /// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute 15 | #ifndef DWMWA_USE_IMMERSIVE_DARK_MODE 16 | #define DWMWA_USE_IMMERSIVE_DARK_MODE 20 17 | #endif 18 | 19 | constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; 20 | 21 | /// Registry key for app theme preference. 22 | /// 23 | /// A value of 0 indicates apps should use dark mode. A non-zero or missing 24 | /// value indicates apps should use light mode. 25 | constexpr const wchar_t kGetPreferredBrightnessRegKey[] = 26 | L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; 27 | constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme"; 28 | 29 | // The number of Win32Window objects that currently exist. 30 | static int g_active_window_count = 0; 31 | 32 | using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); 33 | 34 | // Scale helper to convert logical scaler values to physical using passed in 35 | // scale factor 36 | int Scale(int source, double scale_factor) { 37 | return static_cast(source * scale_factor); 38 | } 39 | 40 | // Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. 41 | // This API is only needed for PerMonitor V1 awareness mode. 42 | void EnableFullDpiSupportIfAvailable(HWND hwnd) { 43 | HMODULE user32_module = LoadLibraryA("User32.dll"); 44 | if (!user32_module) { 45 | return; 46 | } 47 | auto enable_non_client_dpi_scaling = 48 | reinterpret_cast( 49 | GetProcAddress(user32_module, "EnableNonClientDpiScaling")); 50 | if (enable_non_client_dpi_scaling != nullptr) { 51 | enable_non_client_dpi_scaling(hwnd); 52 | } 53 | FreeLibrary(user32_module); 54 | } 55 | 56 | } // namespace 57 | 58 | // Manages the Win32Window's window class registration. 59 | class WindowClassRegistrar { 60 | public: 61 | ~WindowClassRegistrar() = default; 62 | 63 | // Returns the singleton registrar instance. 64 | static WindowClassRegistrar* GetInstance() { 65 | if (!instance_) { 66 | instance_ = new WindowClassRegistrar(); 67 | } 68 | return instance_; 69 | } 70 | 71 | // Returns the name of the window class, registering the class if it hasn't 72 | // previously been registered. 73 | const wchar_t* GetWindowClass(); 74 | 75 | // Unregisters the window class. Should only be called if there are no 76 | // instances of the window. 77 | void UnregisterWindowClass(); 78 | 79 | private: 80 | WindowClassRegistrar() = default; 81 | 82 | static WindowClassRegistrar* instance_; 83 | 84 | bool class_registered_ = false; 85 | }; 86 | 87 | WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; 88 | 89 | const wchar_t* WindowClassRegistrar::GetWindowClass() { 90 | if (!class_registered_) { 91 | WNDCLASS window_class{}; 92 | window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); 93 | window_class.lpszClassName = kWindowClassName; 94 | window_class.style = CS_HREDRAW | CS_VREDRAW; 95 | window_class.cbClsExtra = 0; 96 | window_class.cbWndExtra = 0; 97 | window_class.hInstance = GetModuleHandle(nullptr); 98 | window_class.hIcon = 99 | LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); 100 | window_class.hbrBackground = 0; 101 | window_class.lpszMenuName = nullptr; 102 | window_class.lpfnWndProc = Win32Window::WndProc; 103 | RegisterClass(&window_class); 104 | class_registered_ = true; 105 | } 106 | return kWindowClassName; 107 | } 108 | 109 | void WindowClassRegistrar::UnregisterWindowClass() { 110 | UnregisterClass(kWindowClassName, nullptr); 111 | class_registered_ = false; 112 | } 113 | 114 | Win32Window::Win32Window() { 115 | ++g_active_window_count; 116 | } 117 | 118 | Win32Window::~Win32Window() { 119 | --g_active_window_count; 120 | Destroy(); 121 | } 122 | 123 | bool Win32Window::Create(const std::wstring& title, 124 | const Point& origin, 125 | const Size& size) { 126 | Destroy(); 127 | 128 | const wchar_t* window_class = 129 | WindowClassRegistrar::GetInstance()->GetWindowClass(); 130 | 131 | const POINT target_point = {static_cast(origin.x), 132 | static_cast(origin.y)}; 133 | HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); 134 | UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); 135 | double scale_factor = dpi / 96.0; 136 | 137 | HWND window = CreateWindow( 138 | window_class, title.c_str(), WS_OVERLAPPEDWINDOW, 139 | Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), 140 | Scale(size.width, scale_factor), Scale(size.height, scale_factor), 141 | nullptr, nullptr, GetModuleHandle(nullptr), this); 142 | 143 | if (!window) { 144 | return false; 145 | } 146 | 147 | UpdateTheme(window); 148 | 149 | return OnCreate(); 150 | } 151 | 152 | bool Win32Window::Show() { 153 | return ShowWindow(window_handle_, SW_SHOWNORMAL); 154 | } 155 | 156 | // static 157 | LRESULT CALLBACK Win32Window::WndProc(HWND const window, 158 | UINT const message, 159 | WPARAM const wparam, 160 | LPARAM const lparam) noexcept { 161 | if (message == WM_NCCREATE) { 162 | auto window_struct = reinterpret_cast(lparam); 163 | SetWindowLongPtr(window, GWLP_USERDATA, 164 | reinterpret_cast(window_struct->lpCreateParams)); 165 | 166 | auto that = static_cast(window_struct->lpCreateParams); 167 | EnableFullDpiSupportIfAvailable(window); 168 | that->window_handle_ = window; 169 | } else if (Win32Window* that = GetThisFromHandle(window)) { 170 | return that->MessageHandler(window, message, wparam, lparam); 171 | } 172 | 173 | return DefWindowProc(window, message, wparam, lparam); 174 | } 175 | 176 | LRESULT 177 | Win32Window::MessageHandler(HWND hwnd, 178 | UINT const message, 179 | WPARAM const wparam, 180 | LPARAM const lparam) noexcept { 181 | switch (message) { 182 | case WM_DESTROY: 183 | window_handle_ = nullptr; 184 | Destroy(); 185 | if (quit_on_close_) { 186 | PostQuitMessage(0); 187 | } 188 | return 0; 189 | 190 | case WM_DPICHANGED: { 191 | auto newRectSize = reinterpret_cast(lparam); 192 | LONG newWidth = newRectSize->right - newRectSize->left; 193 | LONG newHeight = newRectSize->bottom - newRectSize->top; 194 | 195 | SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, 196 | newHeight, SWP_NOZORDER | SWP_NOACTIVATE); 197 | 198 | return 0; 199 | } 200 | case WM_SIZE: { 201 | RECT rect = GetClientArea(); 202 | if (child_content_ != nullptr) { 203 | // Size and position the child window. 204 | MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, 205 | rect.bottom - rect.top, TRUE); 206 | } 207 | return 0; 208 | } 209 | 210 | case WM_ACTIVATE: 211 | if (child_content_ != nullptr) { 212 | SetFocus(child_content_); 213 | } 214 | return 0; 215 | 216 | case WM_DWMCOLORIZATIONCOLORCHANGED: 217 | UpdateTheme(hwnd); 218 | return 0; 219 | } 220 | 221 | return DefWindowProc(window_handle_, message, wparam, lparam); 222 | } 223 | 224 | void Win32Window::Destroy() { 225 | OnDestroy(); 226 | 227 | if (window_handle_) { 228 | DestroyWindow(window_handle_); 229 | window_handle_ = nullptr; 230 | } 231 | if (g_active_window_count == 0) { 232 | WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); 233 | } 234 | } 235 | 236 | Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { 237 | return reinterpret_cast( 238 | GetWindowLongPtr(window, GWLP_USERDATA)); 239 | } 240 | 241 | void Win32Window::SetChildContent(HWND content) { 242 | child_content_ = content; 243 | SetParent(content, window_handle_); 244 | RECT frame = GetClientArea(); 245 | 246 | MoveWindow(content, frame.left, frame.top, frame.right - frame.left, 247 | frame.bottom - frame.top, true); 248 | 249 | SetFocus(child_content_); 250 | } 251 | 252 | RECT Win32Window::GetClientArea() { 253 | RECT frame; 254 | GetClientRect(window_handle_, &frame); 255 | return frame; 256 | } 257 | 258 | HWND Win32Window::GetHandle() { 259 | return window_handle_; 260 | } 261 | 262 | void Win32Window::SetQuitOnClose(bool quit_on_close) { 263 | quit_on_close_ = quit_on_close; 264 | } 265 | 266 | bool Win32Window::OnCreate() { 267 | // No-op; provided for subclasses. 268 | return true; 269 | } 270 | 271 | void Win32Window::OnDestroy() { 272 | // No-op; provided for subclasses. 273 | } 274 | 275 | void Win32Window::UpdateTheme(HWND const window) { 276 | DWORD light_mode; 277 | DWORD light_mode_size = sizeof(light_mode); 278 | LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, 279 | kGetPreferredBrightnessRegValue, 280 | RRF_RT_REG_DWORD, nullptr, &light_mode, 281 | &light_mode_size); 282 | 283 | if (result == ERROR_SUCCESS) { 284 | BOOL enable_dark_mode = light_mode == 0; 285 | DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, 286 | &enable_dark_mode, sizeof(enable_dark_mode)); 287 | } 288 | } 289 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/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 a win32 window with |title| that is positioned and sized 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 this function will scale the inputted width and height as 35 | // as appropriate for the default monitor. The window is invisible until 36 | // |Show| is called. Returns true if the window was created successfully. 37 | bool Create(const std::wstring& title, const Point& origin, const Size& size); 38 | 39 | // Show the current window. Returns true if the window was successfully shown. 40 | bool Show(); 41 | 42 | // Release OS resources associated with window. 43 | void Destroy(); 44 | 45 | // Inserts |content| into the window tree. 46 | void SetChildContent(HWND content); 47 | 48 | // Returns the backing Window handle to enable clients to set icon and other 49 | // window properties. Returns nullptr if the window has been destroyed. 50 | HWND GetHandle(); 51 | 52 | // If true, closing this window will quit the application. 53 | void SetQuitOnClose(bool quit_on_close); 54 | 55 | // Return a RECT representing the bounds of the current client area. 56 | RECT GetClientArea(); 57 | 58 | protected: 59 | // Processes and route salient window messages for mouse handling, 60 | // size change and DPI. Delegates handling of these to member overloads that 61 | // inheriting classes can handle. 62 | virtual LRESULT MessageHandler(HWND window, 63 | UINT const message, 64 | WPARAM const wparam, 65 | LPARAM const lparam) noexcept; 66 | 67 | // Called when CreateAndShow is called, allowing subclass window-related 68 | // setup. Subclasses should return false if setup fails. 69 | virtual bool OnCreate(); 70 | 71 | // Called when Destroy is called. 72 | virtual void OnDestroy(); 73 | 74 | private: 75 | friend class WindowClassRegistrar; 76 | 77 | // OS callback called by message pump. Handles the WM_NCCREATE message which 78 | // is passed when the non-client area is being created and enables automatic 79 | // non-client DPI scaling so that the non-client area automatically 80 | // responds to changes in DPI. All other messages are handled by 81 | // MessageHandler. 82 | static LRESULT CALLBACK WndProc(HWND const window, 83 | UINT const message, 84 | WPARAM const wparam, 85 | LPARAM const lparam) noexcept; 86 | 87 | // Retrieves a class instance pointer for |window| 88 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 89 | 90 | // Update the window frame's theme to match the system theme. 91 | static void UpdateTheme(HWND const window); 92 | 93 | bool quit_on_close_ = false; 94 | 95 | // window handle for top level window. 96 | HWND window_handle_ = nullptr; 97 | 98 | // window handle for hosted content. 99 | HWND child_content_ = nullptr; 100 | }; 101 | 102 | #endif // RUNNER_WIN32_WINDOW_H_ 103 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/lib/shortcut_menu_extender.dart: -------------------------------------------------------------------------------- 1 | export 'package:shortcut_menu_extender_platform_interface/shortcut_menu_extender_platform_interface.dart' 2 | show ShortcutMenuListener; 3 | export 'package:shortcut_menu_extender_windows/shortcut_menu_extender_windows.dart' 4 | show shortcutMenuExtenderCommand; 5 | 6 | export 'src/shortcut_menu_extender.dart'; 7 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/lib/src/shortcut_menu_extender.dart: -------------------------------------------------------------------------------- 1 | import 'package:shortcut_menu_extender_platform_interface/shortcut_menu_extender_platform_interface.dart'; 2 | 3 | /// Extending global shortcut menus. 4 | class ShortcutMenuExtender { 5 | Future getPlatformVersion() { 6 | return ShortcutMenuExtenderPlatform.instance.getPlatformVersion(); 7 | } 8 | 9 | /// Register a shortcut menu. 10 | /// 11 | /// [key] is the unique identifier of the shortcut menu. 12 | /// [name] is the name of the shortcut menu. 13 | /// [executable] is the executable path of the shortcut menu. 14 | /// [useDefaultIcon] is whether to use the default icon of the executable file. 15 | /// 16 | /// Sample usage: 17 | /// 18 | /// ```dart 19 | /// shortcutMenuExtender.register( 20 | /// 'MyFlutterApp', 21 | /// name: 'Open With MyFlutterApp', 22 | /// executable: Platform.resolvedExecutable, 23 | /// useDefaultIcon: true, 24 | /// ); 25 | /// ``` 26 | Future register( 27 | String key, { 28 | required String name, 29 | required String executable, 30 | bool useDefaultIcon = true, 31 | }) { 32 | return ShortcutMenuExtenderPlatform.instance.register( 33 | key, 34 | name: name, 35 | executable: executable, 36 | useDefaultIcon: useDefaultIcon, 37 | ); 38 | } 39 | 40 | /// Unregister a shortcut menu. 41 | /// 42 | /// [key] is the unique identifier of the shortcut menu. 43 | Future unregister(String key) { 44 | return ShortcutMenuExtenderPlatform.instance.unregister(key); 45 | } 46 | 47 | /// Add a listener to listen for shortcut menu events. 48 | void addListener(ShortcutMenuListener listener) { 49 | return ShortcutMenuExtenderPlatform.instance.addListener(listener); 50 | } 51 | 52 | /// Remove a listener. 53 | void removeListener(ShortcutMenuListener listener) { 54 | return ShortcutMenuExtenderPlatform.instance.removeListener(listener); 55 | } 56 | } 57 | 58 | final shortcutMenuExtender = ShortcutMenuExtender(); 59 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: shortcut_menu_extender 2 | description: "This plugin allows Flutter apps to Extending global shortcut menus." 3 | version: 0.2.0 4 | homepage: https://github.com/leanflutter/shortcut_menu_extender 5 | 6 | environment: 7 | sdk: ">=3.0.0 <4.0.0" 8 | flutter: ">=3.3.0" 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | shortcut_menu_extender_platform_interface: ^0.2.0 14 | shortcut_menu_extender_windows: ^0.2.0 15 | 16 | dev_dependencies: 17 | flutter_test: 18 | sdk: flutter 19 | mostly_reasonable_lints: ^0.1.1 20 | 21 | flutter: 22 | plugin: 23 | platforms: 24 | windows: 25 | default_package: shortcut_menu_extender_windows 26 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender_platform_interface/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. 26 | /pubspec.lock 27 | **/doc/api/ 28 | .dart_tool/ 29 | build/ 30 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender_platform_interface/.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: "db7ef5bf9f59442b0e200a90587e8fa5e0c6336a" 8 | channel: "stable" 9 | 10 | project_type: plugin 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a 17 | base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a 18 | 19 | # User provided section 20 | 21 | # List of Local paths (relative to this file) that should be 22 | # ignored by the migrate tool. 23 | # 24 | # Files that are not part of the templates will be ignored by default. 25 | unmanaged_files: 26 | - 'lib/main.dart' 27 | - 'ios/Runner.xcodeproj/project.pbxproj' 28 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender_platform_interface/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.2.0 2 | 3 | * chore: Update to new version of shortcut_menu_extender_platform_interface 4 | 5 | ## 0.1.1 6 | 7 | * chore: Add dartdoc comments to public API 8 | 9 | ## 0.1.0 10 | 11 | * First release. 12 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender_platform_interface/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023-2024 LiJianying 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. -------------------------------------------------------------------------------- /packages/shortcut_menu_extender_platform_interface/README.md: -------------------------------------------------------------------------------- 1 | # shortcut_menu_extender_platform_interface 2 | 3 | A new Flutter plugin project. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter 8 | [plug-in package](https://flutter.dev/developing-packages/), 9 | a specialized package that includes platform-specific implementation code for 10 | Android and/or iOS. 11 | 12 | For help getting started with Flutter development, view the 13 | [online documentation](https://flutter.dev/docs), which offers tutorials, 14 | samples, guidance on mobile development, and a full API reference. 15 | 16 | The plugin project was generated without specifying the `--platforms` flag, no platforms are currently supported. 17 | To add platforms, run `flutter create -t plugin --platforms .` in this directory. 18 | You can also find a detailed instruction on how to add platforms in the `pubspec.yaml` at https://flutter.dev/docs/development/packages-and-plugins/developing-packages#plugin-platforms. 19 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender_platform_interface/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:mostly_reasonable_lints/flutter.yaml 2 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender_platform_interface/lib/shortcut_menu_extender_platform_interface.dart: -------------------------------------------------------------------------------- 1 | export 'src/shortcut_menu_extender_method_channel.dart'; 2 | export 'src/shortcut_menu_extender_platform.dart'; 3 | export 'src/shortcut_menu_listener.dart'; 4 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender_platform_interface/lib/src/shortcut_menu_extender_method_channel.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | import 'package:flutter/services.dart'; 3 | import 'package:shortcut_menu_extender_platform_interface/src/shortcut_menu_extender_platform.dart'; 4 | import 'package:shortcut_menu_extender_platform_interface/src/shortcut_menu_listener.dart'; 5 | 6 | /// An implementation of [ShortcutMenuExtenderPlatform] that uses method channels. 7 | class MethodChannelShortcutMenuExtender extends ShortcutMenuExtenderPlatform { 8 | final ObserverList _listeners = 9 | ObserverList(); 10 | 11 | List get listeners { 12 | final List localListeners = 13 | List.from(_listeners); 14 | return localListeners; 15 | } 16 | 17 | Map _parseArgs(String argsRawString) { 18 | final args = argsRawString.split('\n'); 19 | final Map map = {}; 20 | for (final arg in args) { 21 | if (arg.isEmpty) continue; 22 | final keyValue = arg.split('='); 23 | map[keyValue.first.toLowerCase()] = keyValue.last; 24 | } 25 | return map; 26 | } 27 | 28 | Future _handleMethodCall(MethodCall call) async { 29 | for (final ShortcutMenuListener listener in listeners) { 30 | if (!_listeners.contains(listener)) { 31 | return; 32 | } 33 | if (call.method == 'onShortcutMenuClicked') { 34 | final args = _parseArgs(call.arguments['raw_args'] as String); 35 | listener.onShortcutMenuClicked( 36 | args['key'], 37 | args['path'], 38 | ); 39 | } else { 40 | throw UnimplementedError(); 41 | } 42 | } 43 | } 44 | 45 | /// The method channel used to interact with the native platform. 46 | @visibleForTesting 47 | final methodChannel = const MethodChannel('shortcut_menu_extender'); 48 | 49 | @override 50 | Future getPlatformVersion() async { 51 | final version = 52 | await methodChannel.invokeMethod('getPlatformVersion'); 53 | return version; 54 | } 55 | 56 | @override 57 | void addListener(ShortcutMenuListener listener) { 58 | _listeners.add(listener); 59 | if (_listeners.isNotEmpty) { 60 | methodChannel.setMethodCallHandler(_handleMethodCall); 61 | } 62 | } 63 | 64 | @override 65 | void removeListener(ShortcutMenuListener listener) { 66 | _listeners.remove(listener); 67 | if (_listeners.isEmpty) { 68 | methodChannel.setMethodCallHandler(null); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender_platform_interface/lib/src/shortcut_menu_extender_platform.dart: -------------------------------------------------------------------------------- 1 | import 'package:plugin_platform_interface/plugin_platform_interface.dart'; 2 | import 'package:shortcut_menu_extender_platform_interface/src/shortcut_menu_extender_method_channel.dart'; 3 | import 'package:shortcut_menu_extender_platform_interface/src/shortcut_menu_listener.dart'; 4 | 5 | abstract class ShortcutMenuExtenderPlatform extends PlatformInterface { 6 | /// Constructs a ShortcutMenuExtenderPlatform. 7 | ShortcutMenuExtenderPlatform() : super(token: _token); 8 | 9 | static final Object _token = Object(); 10 | 11 | static ShortcutMenuExtenderPlatform _instance = 12 | MethodChannelShortcutMenuExtender(); 13 | 14 | /// The default instance of [ShortcutMenuExtenderPlatform] to use. 15 | /// 16 | /// Defaults to [MethodChannelShortcutMenuExtender]. 17 | static ShortcutMenuExtenderPlatform get instance => _instance; 18 | 19 | /// Platform-specific implementations should set this with their own 20 | /// platform-specific class that extends [ShortcutMenuExtenderPlatform] when 21 | /// they register themselves. 22 | static set instance(ShortcutMenuExtenderPlatform instance) { 23 | PlatformInterface.verifyToken(instance, _token); 24 | _instance = instance; 25 | } 26 | 27 | Future getPlatformVersion() { 28 | throw UnimplementedError('platformVersion() has not been implemented.'); 29 | } 30 | 31 | Future register( 32 | String key, { 33 | required String name, 34 | required String executable, 35 | bool useDefaultIcon = true, 36 | }) { 37 | throw UnimplementedError('register() has not been implemented.'); 38 | } 39 | 40 | Future unregister(String key) { 41 | throw UnimplementedError('register() has not been implemented.'); 42 | } 43 | 44 | void addListener(ShortcutMenuListener listener) { 45 | throw UnimplementedError('addListener() has not been implemented.'); 46 | } 47 | 48 | void removeListener(ShortcutMenuListener listener) { 49 | throw UnimplementedError('removeListener() has not been implemented.'); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender_platform_interface/lib/src/shortcut_menu_listener.dart: -------------------------------------------------------------------------------- 1 | mixin class ShortcutMenuListener { 2 | void onShortcutMenuClicked(String key, String path) { 3 | throw UnimplementedError( 4 | 'onShortcutMenuClicked() has not been implemented.', 5 | ); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender_platform_interface/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: shortcut_menu_extender_platform_interface 2 | description: "A common platform interface for the shortcut_menu_extender plugin." 3 | version: 0.2.0 4 | homepage: https://github.com/leanflutter/shortcut_menu_extender 5 | 6 | environment: 7 | sdk: ">=3.0.0 <4.0.0" 8 | flutter: ">=3.3.0" 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | plugin_platform_interface: ^2.0.2 14 | 15 | dev_dependencies: 16 | flutter_test: 17 | sdk: flutter 18 | mostly_reasonable_lints: ^0.1.1 19 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender_windows/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. 26 | /pubspec.lock 27 | **/doc/api/ 28 | .dart_tool/ 29 | build/ 30 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender_windows/.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: "db7ef5bf9f59442b0e200a90587e8fa5e0c6336a" 8 | channel: "stable" 9 | 10 | project_type: plugin 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a 17 | base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a 18 | - platform: windows 19 | create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a 20 | base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a 21 | 22 | # User provided section 23 | 24 | # List of Local paths (relative to this file) that should be 25 | # ignored by the migrate tool. 26 | # 27 | # Files that are not part of the templates will be ignored by default. 28 | unmanaged_files: 29 | - 'lib/main.dart' 30 | - 'ios/Runner.xcodeproj/project.pbxproj' 31 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender_windows/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.2.0 2 | 3 | * chore: Update to new version of shortcut_menu_extender_platform_interface 4 | * Bump win32 to 5.15.0 & win32_registry to 2.1.0 5 | 6 | ## 0.1.1 7 | 8 | * chore: Add dartdoc comments to public API 9 | 10 | ## 0.1.0 11 | 12 | * First release. 13 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender_windows/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023-2024 LiJianying 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. -------------------------------------------------------------------------------- /packages/shortcut_menu_extender_windows/README.md: -------------------------------------------------------------------------------- 1 | # shortcut_menu_extender_windows 2 | 3 | A new Flutter plugin project. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter 8 | [plug-in package](https://flutter.dev/developing-packages/), 9 | a specialized package that includes platform-specific implementation code for 10 | Android and/or iOS. 11 | 12 | For help getting started with Flutter development, view the 13 | [online documentation](https://flutter.dev/docs), which offers tutorials, 14 | samples, guidance on mobile development, and a full API reference. 15 | 16 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender_windows/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:mostly_reasonable_lints/flutter.yaml 2 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender_windows/lib/shortcut_menu_extender_windows.dart: -------------------------------------------------------------------------------- 1 | export 'package:shortcut_menu_extender_windows/src/shortcut_menu_extender_command.dart'; 2 | export 'package:shortcut_menu_extender_windows/src/shortcut_menu_extender_windows.dart'; 3 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender_windows/lib/src/shortcut_menu_extender_command.dart: -------------------------------------------------------------------------------- 1 | import 'package:args/args.dart'; 2 | import 'package:win32_registry/win32_registry.dart'; 3 | 4 | const _kCommandMain = 'shortcut_menu_extender'; 5 | const _kCommandRegister = 'shortcut_menu_extender_register'; 6 | const _kCommandUnregister = 'shortcut_menu_extender_unregister'; 7 | 8 | /// Register shortcut menu. 9 | void registerShortcutMenu( 10 | String key, { 11 | required String name, 12 | required String executable, 13 | String? icon, 14 | }) { 15 | final regValueMenu = RegistryValue.string( 16 | '', 17 | name, 18 | ); 19 | final regValueMenuIcon = RegistryValue.string( 20 | 'Icon', 21 | icon ?? '', 22 | ); 23 | final regValueMenuCommand = RegistryValue.string( 24 | '', 25 | '$executable shortcut_menu_extender --key $key --path "%1"', 26 | ); 27 | // Register shortcut menu for file. 28 | final regKeyForFile = Registry.classesRoot.createKey('*\\shell\\$key'); 29 | regKeyForFile.createValue(regValueMenu); 30 | if ((icon ?? '').isNotEmpty) { 31 | regKeyForFile.createValue(regValueMenuIcon); 32 | } 33 | final regKeyForFileCommand = regKeyForFile.createKey('command'); 34 | regKeyForFileCommand.createValue(regValueMenuCommand); 35 | 36 | // Register shortcut menu for folder. 37 | final regKeyForFolder = Registry.classesRoot.createKey('Folder\\shell\\$key'); 38 | regKeyForFolder.createValue(regValueMenu); 39 | if ((icon ?? '').isNotEmpty) { 40 | regKeyForFolder.createValue(regValueMenuIcon); 41 | } 42 | final regKeyForFolderCommand = regKeyForFolder.createKey('command'); 43 | regKeyForFolderCommand.createValue(regValueMenuCommand); 44 | } 45 | 46 | /// Unregister shortcut menu. 47 | void unregisterShortcutMenu(String key) { 48 | // Unregister shortcut menu for file. 49 | final String keyForFile = '*\\shell\\$key'; 50 | Registry.classesRoot.deleteKey(keyForFile, recursive: true); 51 | 52 | // Unregister shortcut menu for folder. 53 | final String keyForFolder = 'Folder\\shell\\$key'; 54 | Registry.classesRoot.deleteKey(keyForFolder, recursive: true); 55 | } 56 | 57 | class ShortcutMenuExtenderCommand { 58 | final ArgParser argParser = ArgParser() 59 | ..addCommand(_kCommandMain, ArgParser()) 60 | ..addCommand( 61 | _kCommandRegister, 62 | ArgParser() 63 | ..addOption('key') 64 | ..addOption('name') 65 | ..addOption('icon') 66 | ..addOption('executable'), 67 | ) 68 | ..addCommand( 69 | _kCommandUnregister, 70 | ArgParser()..addOption('key'), 71 | ); 72 | 73 | /// Run command if needed. 74 | bool runIfNeeded(List args) { 75 | try { 76 | final results = argParser.parse(args); 77 | final command = results.command; 78 | switch (command?.name) { 79 | case _kCommandRegister: 80 | registerShortcutMenu( 81 | command?['key']!, 82 | name: Uri.decodeQueryComponent(command?['name']!), 83 | executable: command?['executable']!, 84 | icon: command?['icon'], 85 | ); 86 | return true; 87 | case _kCommandUnregister: 88 | unregisterShortcutMenu( 89 | command?['key']!, 90 | ); 91 | return true; 92 | } 93 | } catch (_) {} 94 | return false; 95 | } 96 | } 97 | 98 | final shortcutMenuExtenderCommand = ShortcutMenuExtenderCommand(); 99 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender_windows/lib/src/shortcut_menu_extender_windows.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ffi'; 2 | import 'dart:io'; 3 | 4 | import 'package:ffi/ffi.dart'; 5 | import 'package:shortcut_menu_extender_platform_interface/shortcut_menu_extender_platform_interface.dart'; 6 | import 'package:win32/win32.dart'; 7 | 8 | class ShortcutMenuExtenderWindows extends ShortcutMenuExtenderPlatform { 9 | final _methodChannelImpl = MethodChannelShortcutMenuExtender(); 10 | 11 | /// Registers the Windows implementation. 12 | static void registerWith() { 13 | ShortcutMenuExtenderPlatform.instance = ShortcutMenuExtenderWindows(); 14 | } 15 | 16 | @override 17 | Future getPlatformVersion() { 18 | return _methodChannelImpl.getPlatformVersion(); 19 | } 20 | 21 | @override 22 | Future register( 23 | String key, { 24 | required String name, 25 | required String executable, 26 | bool useDefaultIcon = true, 27 | }) async { 28 | await _runWithAdministrator(Platform.resolvedExecutable, [ 29 | 'shortcut_menu_extender_register', 30 | '--key', 31 | key, 32 | '--name', 33 | Uri.encodeQueryComponent(name), 34 | ...useDefaultIcon 35 | ? [ 36 | '--icon', 37 | '$executable,0', 38 | ] 39 | : [], 40 | '--executable', 41 | executable, 42 | ]); 43 | } 44 | 45 | @override 46 | Future unregister(String key) async { 47 | await _runWithAdministrator( 48 | Platform.resolvedExecutable, 49 | [ 50 | 'shortcut_menu_extender_unregister', 51 | '--key', 52 | key, 53 | ], 54 | ); 55 | } 56 | 57 | @override 58 | void addListener(ShortcutMenuListener listener) { 59 | _methodChannelImpl.addListener(listener); 60 | } 61 | 62 | @override 63 | void removeListener(ShortcutMenuListener listener) { 64 | _methodChannelImpl.removeListener(listener); 65 | } 66 | 67 | Future _runWithAdministrator( 68 | String executable, 69 | List args, 70 | ) async { 71 | final psi = calloc(); 72 | psi.ref.cbSize = sizeOf(); 73 | psi.ref.lpFile = TEXT(executable); 74 | psi.ref.lpParameters = TEXT(args.join(' ')); 75 | psi.ref.nShow = SW_SHOWNORMAL; 76 | psi.ref.lpVerb = TEXT('runas'); 77 | if (ShellExecuteEx(psi) == 0) { 78 | free(psi); 79 | return Future.error('Failed to execute as admin'); 80 | } 81 | 82 | WaitForSingleObject(psi.ref.hProcess, INFINITE); 83 | final exitCode = calloc(); 84 | GetExitCodeProcess(psi.ref.hProcess, exitCode); 85 | CloseHandle(psi.ref.hProcess); 86 | free(psi); 87 | return exitCode.value == 0 88 | ? Future.value() 89 | : Future.error('Failed to execute as admin'); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender_windows/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: shortcut_menu_extender_windows 2 | description: "The Windows implementation of shortcut_menu_extender." 3 | version: 0.2.0 4 | homepage: https://github.com/leanflutter/shortcut_menu_extender 5 | 6 | environment: 7 | sdk: ">=3.0.0 <4.0.0" 8 | flutter: ">=3.3.0" 9 | 10 | dependencies: 11 | args: ^2.4.2 12 | ffi: ^2.1.0 13 | flutter: 14 | sdk: flutter 15 | shortcut_menu_extender_platform_interface: ^0.2.0 16 | win32: ^5.12.0 17 | win32_registry: ^2.1.0 18 | 19 | dev_dependencies: 20 | flutter_test: 21 | sdk: flutter 22 | mostly_reasonable_lints: ^0.1.1 23 | 24 | flutter: 25 | plugin: 26 | implements: shortcut_menu_extender 27 | platforms: 28 | windows: 29 | pluginClass: ShortcutMenuExtenderWindowsPluginCApi 30 | dartPluginClass: ShortcutMenuExtenderWindows 31 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender_windows/test/src/shortcut_menu_extender_command_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_test/flutter_test.dart'; 2 | import 'package:shortcut_menu_extender_windows/src/shortcut_menu_extender_command.dart'; 3 | 4 | void main() { 5 | group('argParser', () { 6 | final argParser = ShortcutMenuExtenderCommand().argParser; 7 | test('shortcut_menu_extender_register#1', () { 8 | final results = argParser.parse(['shortcut_menu_extender_register']); 9 | expect(results.command?.name, 'shortcut_menu_extender_register'); 10 | }); 11 | test('shortcut_menu_extender_register#2', () { 12 | final results = argParser.parse([ 13 | 'shortcut_menu_extender_register', 14 | '--key', 15 | 'example-key', 16 | '--name', 17 | 'example-name', 18 | '--icon', 19 | 'example-icon', 20 | '--executable', 21 | 'example-executable', 22 | ]); 23 | final command = results.command; 24 | expect(command?.name, 'shortcut_menu_extender_register'); 25 | expect(command?['key'], 'example-key'); 26 | expect(command?['name'], 'example-name'); 27 | expect(command?['icon'], 'example-icon'); 28 | expect(command?['executable'], 'example-executable'); 29 | }); 30 | test('shortcut_menu_extender_unregister#1', () { 31 | final results = argParser.parse(['shortcut_menu_extender_unregister']); 32 | expect(results.command?.name, 'shortcut_menu_extender_unregister'); 33 | }); 34 | test('shortcut_menu_extender_unregister#2', () { 35 | final results = argParser.parse([ 36 | 'shortcut_menu_extender_unregister', 37 | '--key', 38 | 'example-key', 39 | ]); 40 | final command = results.command; 41 | expect(command?.name, 'shortcut_menu_extender_unregister'); 42 | expect(command?['key'], 'example-key'); 43 | }); 44 | }); 45 | } 46 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender_windows/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 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender_windows/windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The Flutter tooling requires that developers have a version of Visual Studio 2 | # installed that includes CMake 3.14 or later. You should not increase this 3 | # version, as doing so will cause the plugin to fail to compile for some 4 | # customers of the plugin. 5 | cmake_minimum_required(VERSION 3.14) 6 | 7 | # Project-level configuration. 8 | set(PROJECT_NAME "shortcut_menu_extender_windows") 9 | project(${PROJECT_NAME} LANGUAGES CXX) 10 | 11 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 12 | # versions of CMake. 13 | cmake_policy(VERSION 3.14...3.25) 14 | 15 | # This value is used when generating builds using this plugin, so it must 16 | # not be changed 17 | set(PLUGIN_NAME "shortcut_menu_extender_windows_plugin") 18 | 19 | # Any new source files that you add to the plugin should be added here. 20 | list(APPEND PLUGIN_SOURCES 21 | "shortcut_menu_extender_windows_plugin.cpp" 22 | "shortcut_menu_extender_windows_plugin.h" 23 | ) 24 | 25 | # Define the plugin library target. Its name must not be changed (see comment 26 | # on PLUGIN_NAME above). 27 | add_library(${PLUGIN_NAME} SHARED 28 | "include/shortcut_menu_extender_windows/shortcut_menu_extender_windows_plugin_c_api.h" 29 | "shortcut_menu_extender_windows_plugin_c_api.cpp" 30 | ${PLUGIN_SOURCES} 31 | ) 32 | 33 | # Apply a standard set of build settings that are configured in the 34 | # application-level CMakeLists.txt. This can be removed for plugins that want 35 | # full control over build settings. 36 | apply_standard_settings(${PLUGIN_NAME}) 37 | 38 | # Symbols are hidden by default to reduce the chance of accidental conflicts 39 | # between plugins. This should not be removed; any symbols that should be 40 | # exported should be explicitly exported with the FLUTTER_PLUGIN_EXPORT macro. 41 | set_target_properties(${PLUGIN_NAME} PROPERTIES 42 | CXX_VISIBILITY_PRESET hidden) 43 | target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL) 44 | target_compile_definitions(${PLUGIN_NAME} PRIVATE _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING) 45 | 46 | # Source include directories and library dependencies. Add any plugin-specific 47 | # dependencies here. 48 | target_include_directories(${PLUGIN_NAME} INTERFACE 49 | "${CMAKE_CURRENT_SOURCE_DIR}/include") 50 | target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin) 51 | 52 | # List of absolute paths to libraries that should be bundled with the plugin. 53 | # This list could contain prebuilt libraries, or libraries created by an 54 | # external build triggered from this build file. 55 | set(shortcut_menu_extender_windows_bundled_libraries 56 | "" 57 | PARENT_SCOPE 58 | ) 59 | 60 | # === Tests === 61 | # These unit tests can be run from a terminal after building the example, or 62 | # from Visual Studio after opening the generated solution file. 63 | 64 | # Only enable test builds when building the example (which sets this variable) 65 | # so that plugin clients aren't building the tests. 66 | if (${include_${PROJECT_NAME}_tests}) 67 | set(TEST_RUNNER "${PROJECT_NAME}_test") 68 | enable_testing() 69 | 70 | # Add the Google Test dependency. 71 | include(FetchContent) 72 | FetchContent_Declare( 73 | googletest 74 | URL https://github.com/google/googletest/archive/release-1.11.0.zip 75 | ) 76 | # Prevent overriding the parent project's compiler/linker settings 77 | set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) 78 | # Disable install commands for gtest so it doesn't end up in the bundle. 79 | set(INSTALL_GTEST OFF CACHE BOOL "Disable installation of googletest" FORCE) 80 | FetchContent_MakeAvailable(googletest) 81 | 82 | # The plugin's C API is not very useful for unit testing, so build the sources 83 | # directly into the test binary rather than using the DLL. 84 | add_executable(${TEST_RUNNER} 85 | test/shortcut_menu_extender_windows_plugin_test.cpp 86 | ${PLUGIN_SOURCES} 87 | ) 88 | apply_standard_settings(${TEST_RUNNER}) 89 | target_include_directories(${TEST_RUNNER} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") 90 | target_link_libraries(${TEST_RUNNER} PRIVATE flutter_wrapper_plugin) 91 | target_link_libraries(${TEST_RUNNER} PRIVATE gtest_main gmock) 92 | # flutter_wrapper_plugin has link dependencies on the Flutter DLL. 93 | add_custom_command(TARGET ${TEST_RUNNER} POST_BUILD 94 | COMMAND ${CMAKE_COMMAND} -E copy_if_different 95 | "${FLUTTER_LIBRARY}" $ 96 | ) 97 | 98 | # Enable automatic test discovery. 99 | include(GoogleTest) 100 | gtest_discover_tests(${TEST_RUNNER}) 101 | endif() 102 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender_windows/windows/include/shortcut_menu_extender_windows/shortcut_menu_extender_windows_plugin_c_api.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifndef FLUTTER_PLUGIN_SHORTCUT_MENU_EXTENDER_WINDOWS_PLUGIN_C_API_H_ 4 | #define FLUTTER_PLUGIN_SHORTCUT_MENU_EXTENDER_WINDOWS_PLUGIN_C_API_H_ 5 | 6 | #include 7 | 8 | #ifdef FLUTTER_PLUGIN_IMPL 9 | #define FLUTTER_PLUGIN_EXPORT __declspec(dllexport) 10 | #else 11 | #define FLUTTER_PLUGIN_EXPORT __declspec(dllimport) 12 | #endif 13 | 14 | #if defined(__cplusplus) 15 | extern "C" { 16 | #endif 17 | 18 | FLUTTER_PLUGIN_EXPORT void 19 | ShortcutMenuExtenderWindowsPluginCApiRegisterWithRegistrar( 20 | FlutterDesktopPluginRegistrarRef registrar); 21 | 22 | FLUTTER_PLUGIN_EXPORT bool ShouldHandleByShortcutMenuExtender(); 23 | FLUTTER_PLUGIN_EXPORT bool ShouldHandleByShortcutMenuExtenderCommand(); 24 | #define SHORTCUTMENU_EXTENDER_MSG_ID (WM_USER + 3) 25 | FLUTTER_PLUGIN_EXPORT void DispatchToShortcutMenuExtender(HWND hwnd); 26 | 27 | #if defined(__cplusplus) 28 | } // extern "C" 29 | #endif 30 | 31 | #endif // FLUTTER_PLUGIN_SHORTCUT_MENU_EXTENDER_WINDOWS_PLUGIN_C_API_H_ 32 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender_windows/windows/shortcut_menu_extender_windows_plugin.cpp: -------------------------------------------------------------------------------- 1 | #include "shortcut_menu_extender_windows_plugin.h" 2 | #include "include/shortcut_menu_extender_windows/shortcut_menu_extender_windows_plugin_c_api.h" 3 | 4 | // This must be included before many other Windows headers. 5 | #include 6 | 7 | // For getPlatformVersion; remove unless needed for your plugin implementation. 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | namespace shortcut_menu_extender_windows { 19 | 20 | // static 21 | void ShortcutMenuExtenderWindowsPlugin::RegisterWithRegistrar( 22 | flutter::PluginRegistrarWindows* registrar) { 23 | auto plugin = std::make_unique( 24 | registrar, 25 | std::make_unique>( 26 | registrar->messenger(), "shortcut_menu_extender", 27 | &flutter::StandardMethodCodec::GetInstance())); 28 | 29 | plugin->channel()->SetMethodCallHandler( 30 | [plugin_pointer = plugin.get()](const auto& call, auto result) { 31 | plugin_pointer->HandleMethodCall(call, std::move(result)); 32 | }); 33 | 34 | registrar->AddPlugin(std::move(plugin)); 35 | } 36 | 37 | ShortcutMenuExtenderWindowsPlugin::ShortcutMenuExtenderWindowsPlugin( 38 | flutter::PluginRegistrarWindows* registrar, 39 | std::unique_ptr> channel) 40 | : registrar_(registrar), channel_(std::move(channel)) { 41 | window_proc_id_ = registrar->RegisterTopLevelWindowProcDelegate( 42 | [this](HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { 43 | return HandleWindowProc(hwnd, message, wparam, lparam); 44 | }); 45 | } 46 | 47 | ShortcutMenuExtenderWindowsPlugin::~ShortcutMenuExtenderWindowsPlugin() {} 48 | 49 | std::optional ShortcutMenuExtenderWindowsPlugin::HandleWindowProc( 50 | HWND hwnd, 51 | UINT message, 52 | WPARAM wparam, 53 | LPARAM lparam) { 54 | switch (message) { 55 | case WM_COPYDATA: 56 | COPYDATASTRUCT* cds = {0}; 57 | cds = (COPYDATASTRUCT*)lparam; 58 | 59 | if (cds->dwData == SHORTCUTMENU_EXTENDER_MSG_ID) { 60 | std::string raw_args((char*)((LPCWSTR)cds->lpData)); 61 | 62 | flutter::EncodableMap args = flutter::EncodableMap(); 63 | args[flutter::EncodableValue("raw_args")] = 64 | flutter::EncodableValue(raw_args.c_str()); 65 | 66 | channel_->InvokeMethod("onShortcutMenuClicked", 67 | std::make_unique(args)); 68 | } 69 | break; 70 | } 71 | return std::nullopt; 72 | } 73 | 74 | void ShortcutMenuExtenderWindowsPlugin::HandleMethodCall( 75 | const flutter::MethodCall& method_call, 76 | std::unique_ptr> result) { 77 | if (method_call.method_name().compare("getPlatformVersion") == 0) { 78 | std::ostringstream version_stream; 79 | version_stream << "Windows "; 80 | if (IsWindows10OrGreater()) { 81 | version_stream << "10+"; 82 | } else if (IsWindows8OrGreater()) { 83 | version_stream << "8"; 84 | } else if (IsWindows7OrGreater()) { 85 | version_stream << "7"; 86 | } 87 | result->Success(flutter::EncodableValue(version_stream.str())); 88 | } else { 89 | result->NotImplemented(); 90 | } 91 | } 92 | 93 | } // namespace shortcut_menu_extender_windows 94 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender_windows/windows/shortcut_menu_extender_windows_plugin.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_PLUGIN_SHORTCUT_MENU_EXTENDER_WINDOWS_PLUGIN_H_ 2 | #define FLUTTER_PLUGIN_SHORTCUT_MENU_EXTENDER_WINDOWS_PLUGIN_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | namespace shortcut_menu_extender_windows { 10 | 11 | class ShortcutMenuExtenderWindowsPlugin : public flutter::Plugin { 12 | public: 13 | static void RegisterWithRegistrar(flutter::PluginRegistrarWindows* registrar); 14 | 15 | ShortcutMenuExtenderWindowsPlugin( 16 | flutter::PluginRegistrarWindows* registrar, 17 | std::unique_ptr> channel); 18 | 19 | flutter::MethodChannel* channel() const { 20 | return channel_.get(); 21 | } 22 | 23 | virtual ~ShortcutMenuExtenderWindowsPlugin(); 24 | 25 | // Disallow copy and assign. 26 | ShortcutMenuExtenderWindowsPlugin(const ShortcutMenuExtenderWindowsPlugin&) = 27 | delete; 28 | ShortcutMenuExtenderWindowsPlugin& operator=( 29 | const ShortcutMenuExtenderWindowsPlugin&) = delete; 30 | 31 | flutter::PluginRegistrarWindows* registrar_; 32 | std::unique_ptr> channel_ = 33 | nullptr; 34 | int32_t window_proc_id_ = -1; 35 | 36 | std::optional HandleWindowProc(HWND hwnd, 37 | UINT message, 38 | WPARAM wparam, 39 | LPARAM lparam); 40 | 41 | // Called when a method is called on this plugin's channel from Dart. 42 | void HandleMethodCall( 43 | const flutter::MethodCall& method_call, 44 | std::unique_ptr> result); 45 | }; 46 | 47 | } // namespace shortcut_menu_extender_windows 48 | 49 | #define SHORTCUTMENU_EXTENDER_MSG_ID (WM_USER + 3) 50 | 51 | #endif // FLUTTER_PLUGIN_SHORTCUT_MENU_EXTENDER_WINDOWS_PLUGIN_H_ 52 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender_windows/windows/shortcut_menu_extender_windows_plugin_c_api.cpp: -------------------------------------------------------------------------------- 1 | #include "include/shortcut_menu_extender_windows/shortcut_menu_extender_windows_plugin_c_api.h" 2 | 3 | #include 4 | 5 | #include "shortcut_menu_extender_windows_plugin.h" 6 | 7 | #include 8 | 9 | void ShortcutMenuExtenderWindowsPluginCApiRegisterWithRegistrar( 10 | FlutterDesktopPluginRegistrarRef registrar) { 11 | shortcut_menu_extender_windows::ShortcutMenuExtenderWindowsPlugin:: 12 | RegisterWithRegistrar( 13 | flutter::PluginRegistrarManager::GetInstance() 14 | ->GetRegistrar(registrar)); 15 | } 16 | 17 | bool ShouldHandleByShortcutMenuExtender() { 18 | int argc; 19 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 20 | if (argv == nullptr || argc < 2) { 21 | return false; 22 | } 23 | 24 | std::wstring_convert> converter; 25 | std::string command = converter.to_bytes(argv[1]); 26 | ::LocalFree(argv); 27 | 28 | return command == "shortcut_menu_extender"; 29 | } 30 | 31 | bool ShouldHandleByShortcutMenuExtenderCommand() { 32 | int argc; 33 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 34 | if (argv == nullptr || argc < 2) { 35 | return false; 36 | } 37 | 38 | std::wstring_convert> converter; 39 | std::string command = converter.to_bytes(argv[1]); 40 | ::LocalFree(argv); 41 | return command == "shortcut_menu_extender_register" || 42 | command == "shortcut_menu_extender_unregister"; 43 | } 44 | 45 | void DispatchToShortcutMenuExtender(HWND hwnd) { 46 | int argc; 47 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 48 | if (argv == nullptr || argc < 2) { 49 | return; 50 | } 51 | 52 | std::wstring_convert> converter; 53 | std::string key = converter.to_bytes(argv[3]); 54 | std::string path = converter.to_bytes(argv[5]); 55 | ::LocalFree(argv); 56 | 57 | std::string raw_args = ""; 58 | raw_args += "KEY=" + key + "\n"; 59 | raw_args += "PATH=" + path + "\n"; 60 | 61 | COPYDATASTRUCT cds = {0}; 62 | cds.dwData = SHORTCUTMENU_EXTENDER_MSG_ID; 63 | cds.cbData = (DWORD)(strlen(raw_args.c_str()) + 1); 64 | cds.lpData = (PVOID)raw_args.c_str(); 65 | 66 | SendMessage(hwnd, WM_COPYDATA, 0, (LPARAM)&cds); 67 | } 68 | -------------------------------------------------------------------------------- /packages/shortcut_menu_extender_windows/windows/test/shortcut_menu_extender_windows_plugin_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "shortcut_menu_extender_windows_plugin.h" 12 | 13 | namespace shortcut_menu_extender_windows { 14 | namespace test { 15 | 16 | namespace { 17 | 18 | using flutter::EncodableMap; 19 | using flutter::EncodableValue; 20 | using flutter::MethodCall; 21 | using flutter::MethodResultFunctions; 22 | 23 | } // namespace 24 | 25 | TEST(ShortcutMenuExtenderWindowsPlugin, GetPlatformVersion) { 26 | ShortcutMenuExtenderWindowsPlugin plugin; 27 | // Save the reply value from the success callback. 28 | std::string result_string; 29 | plugin.HandleMethodCall( 30 | MethodCall("getPlatformVersion", std::make_unique()), 31 | std::make_unique>( 32 | [&result_string](const EncodableValue* result) { 33 | result_string = std::get(*result); 34 | }, 35 | nullptr, nullptr)); 36 | 37 | // Since the exact string varies by host, just ensure that it's a string 38 | // with the expected format. 39 | EXPECT_TRUE(result_string.rfind("Windows ", 0) == 0); 40 | } 41 | 42 | } // namespace test 43 | } // namespace shortcut_menu_extender_windows 44 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | ansi_styles: 5 | dependency: transitive 6 | description: 7 | name: ansi_styles 8 | sha256: "9c656cc12b3c27b17dd982b2cc5c0cfdfbdabd7bc8f3ae5e8542d9867b47ce8a" 9 | url: "https://pub.dev" 10 | source: hosted 11 | version: "0.3.2+1" 12 | args: 13 | dependency: transitive 14 | description: 15 | name: args 16 | sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 17 | url: "https://pub.dev" 18 | source: hosted 19 | version: "2.4.2" 20 | async: 21 | dependency: transitive 22 | description: 23 | name: async 24 | sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" 25 | url: "https://pub.dev" 26 | source: hosted 27 | version: "2.11.0" 28 | boolean_selector: 29 | dependency: transitive 30 | description: 31 | name: boolean_selector 32 | sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" 33 | url: "https://pub.dev" 34 | source: hosted 35 | version: "2.1.1" 36 | charcode: 37 | dependency: transitive 38 | description: 39 | name: charcode 40 | sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306 41 | url: "https://pub.dev" 42 | source: hosted 43 | version: "1.3.1" 44 | cli_launcher: 45 | dependency: transitive 46 | description: 47 | name: cli_launcher 48 | sha256: "5e7e0282b79e8642edd6510ee468ae2976d847a0a29b3916e85f5fa1bfe24005" 49 | url: "https://pub.dev" 50 | source: hosted 51 | version: "0.3.1" 52 | cli_util: 53 | dependency: transitive 54 | description: 55 | name: cli_util 56 | sha256: c05b7406fdabc7a49a3929d4af76bcaccbbffcbcdcf185b082e1ae07da323d19 57 | url: "https://pub.dev" 58 | source: hosted 59 | version: "0.4.1" 60 | collection: 61 | dependency: transitive 62 | description: 63 | name: collection 64 | sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a 65 | url: "https://pub.dev" 66 | source: hosted 67 | version: "1.18.0" 68 | conventional_commit: 69 | dependency: transitive 70 | description: 71 | name: conventional_commit 72 | sha256: dec15ad1118f029c618651a4359eb9135d8b88f761aa24e4016d061cd45948f2 73 | url: "https://pub.dev" 74 | source: hosted 75 | version: "0.6.0+1" 76 | file: 77 | dependency: transitive 78 | description: 79 | name: file 80 | sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" 81 | url: "https://pub.dev" 82 | source: hosted 83 | version: "6.1.4" 84 | glob: 85 | dependency: transitive 86 | description: 87 | name: glob 88 | sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" 89 | url: "https://pub.dev" 90 | source: hosted 91 | version: "2.1.2" 92 | graphs: 93 | dependency: transitive 94 | description: 95 | name: graphs 96 | sha256: aedc5a15e78fc65a6e23bcd927f24c64dd995062bcd1ca6eda65a3cff92a4d19 97 | url: "https://pub.dev" 98 | source: hosted 99 | version: "2.3.1" 100 | http: 101 | dependency: transitive 102 | description: 103 | name: http 104 | sha256: d4872660c46d929f6b8a9ef4e7a7eff7e49bbf0c4ec3f385ee32df5119175139 105 | url: "https://pub.dev" 106 | source: hosted 107 | version: "1.1.2" 108 | http_parser: 109 | dependency: transitive 110 | description: 111 | name: http_parser 112 | sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" 113 | url: "https://pub.dev" 114 | source: hosted 115 | version: "4.0.2" 116 | io: 117 | dependency: transitive 118 | description: 119 | name: io 120 | sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" 121 | url: "https://pub.dev" 122 | source: hosted 123 | version: "1.0.4" 124 | json_annotation: 125 | dependency: transitive 126 | description: 127 | name: json_annotation 128 | sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467 129 | url: "https://pub.dev" 130 | source: hosted 131 | version: "4.8.1" 132 | matcher: 133 | dependency: transitive 134 | description: 135 | name: matcher 136 | sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb 137 | url: "https://pub.dev" 138 | source: hosted 139 | version: "0.12.16+1" 140 | melos: 141 | dependency: "direct dev" 142 | description: 143 | name: melos 144 | sha256: "96e64bbade5712c3f010137e195bca9f1b351fac34ab1f322af492ae34032067" 145 | url: "https://pub.dev" 146 | source: hosted 147 | version: "3.4.0" 148 | meta: 149 | dependency: transitive 150 | description: 151 | name: meta 152 | sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 153 | url: "https://pub.dev" 154 | source: hosted 155 | version: "1.11.0" 156 | mustache_template: 157 | dependency: transitive 158 | description: 159 | name: mustache_template 160 | sha256: a46e26f91445bfb0b60519be280555b06792460b27b19e2b19ad5b9740df5d1c 161 | url: "https://pub.dev" 162 | source: hosted 163 | version: "2.0.0" 164 | path: 165 | dependency: transitive 166 | description: 167 | name: path 168 | sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" 169 | url: "https://pub.dev" 170 | source: hosted 171 | version: "1.9.0" 172 | platform: 173 | dependency: transitive 174 | description: 175 | name: platform 176 | sha256: "0a279f0707af40c890e80b1e9df8bb761694c074ba7e1d4ab1bc4b728e200b59" 177 | url: "https://pub.dev" 178 | source: hosted 179 | version: "3.1.3" 180 | pool: 181 | dependency: transitive 182 | description: 183 | name: pool 184 | sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" 185 | url: "https://pub.dev" 186 | source: hosted 187 | version: "1.5.1" 188 | process: 189 | dependency: transitive 190 | description: 191 | name: process 192 | sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09" 193 | url: "https://pub.dev" 194 | source: hosted 195 | version: "4.2.4" 196 | prompts: 197 | dependency: transitive 198 | description: 199 | name: prompts 200 | sha256: "3773b845e85a849f01e793c4fc18a45d52d7783b4cb6c0569fad19f9d0a774a1" 201 | url: "https://pub.dev" 202 | source: hosted 203 | version: "2.0.0" 204 | pub_semver: 205 | dependency: transitive 206 | description: 207 | name: pub_semver 208 | sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" 209 | url: "https://pub.dev" 210 | source: hosted 211 | version: "2.1.4" 212 | pub_updater: 213 | dependency: transitive 214 | description: 215 | name: pub_updater 216 | sha256: b06600619c8c219065a548f8f7c192b3e080beff95488ed692780f48f69c0625 217 | url: "https://pub.dev" 218 | source: hosted 219 | version: "0.3.1" 220 | pubspec: 221 | dependency: transitive 222 | description: 223 | name: pubspec 224 | sha256: f534a50a2b4d48dc3bc0ec147c8bd7c304280fff23b153f3f11803c4d49d927e 225 | url: "https://pub.dev" 226 | source: hosted 227 | version: "2.3.0" 228 | quiver: 229 | dependency: transitive 230 | description: 231 | name: quiver 232 | sha256: b1c1ac5ce6688d77f65f3375a9abb9319b3cb32486bdc7a1e0fdf004d7ba4e47 233 | url: "https://pub.dev" 234 | source: hosted 235 | version: "3.2.1" 236 | source_span: 237 | dependency: transitive 238 | description: 239 | name: source_span 240 | sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" 241 | url: "https://pub.dev" 242 | source: hosted 243 | version: "1.10.0" 244 | stack_trace: 245 | dependency: transitive 246 | description: 247 | name: stack_trace 248 | sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" 249 | url: "https://pub.dev" 250 | source: hosted 251 | version: "1.11.1" 252 | stream_channel: 253 | dependency: transitive 254 | description: 255 | name: stream_channel 256 | sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 257 | url: "https://pub.dev" 258 | source: hosted 259 | version: "2.1.2" 260 | string_scanner: 261 | dependency: transitive 262 | description: 263 | name: string_scanner 264 | sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" 265 | url: "https://pub.dev" 266 | source: hosted 267 | version: "1.2.0" 268 | term_glyph: 269 | dependency: transitive 270 | description: 271 | name: term_glyph 272 | sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 273 | url: "https://pub.dev" 274 | source: hosted 275 | version: "1.2.1" 276 | test_api: 277 | dependency: transitive 278 | description: 279 | name: test_api 280 | sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" 281 | url: "https://pub.dev" 282 | source: hosted 283 | version: "0.7.0" 284 | typed_data: 285 | dependency: transitive 286 | description: 287 | name: typed_data 288 | sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c 289 | url: "https://pub.dev" 290 | source: hosted 291 | version: "1.3.2" 292 | uri: 293 | dependency: transitive 294 | description: 295 | name: uri 296 | sha256: "889eea21e953187c6099802b7b4cf5219ba8f3518f604a1033064d45b1b8268a" 297 | url: "https://pub.dev" 298 | source: hosted 299 | version: "1.0.0" 300 | web: 301 | dependency: transitive 302 | description: 303 | name: web 304 | sha256: edc8a9573dd8c5a83a183dae1af2b6fd4131377404706ca4e5420474784906fa 305 | url: "https://pub.dev" 306 | source: hosted 307 | version: "0.4.0" 308 | yaml: 309 | dependency: transitive 310 | description: 311 | name: yaml 312 | sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" 313 | url: "https://pub.dev" 314 | source: hosted 315 | version: "3.1.2" 316 | yaml_edit: 317 | dependency: transitive 318 | description: 319 | name: yaml_edit 320 | sha256: "1579d4a0340a83cf9e4d580ea51a16329c916973bffd5bd4b45e911b25d46bfd" 321 | url: "https://pub.dev" 322 | source: hosted 323 | version: "2.1.1" 324 | sdks: 325 | dart: ">=3.2.0 <4.0.0" 326 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: shortcut_menu_extender_workspace 2 | publish_to: "none" 3 | 4 | environment: 5 | sdk: ">=3.0.0 <4.0.0" 6 | 7 | dev_dependencies: 8 | melos: ^3.1.0 9 | --------------------------------------------------------------------------------