File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed
Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,9 @@ bool _initialUriIsHandled = false;
1212void main () {
1313 if (Platform .isMacOS || Platform .isWindows) {
1414 enableUniLinksDesktop ();
15+ if (Platform .isWindows) {
16+ registerProtocol ('unilinks' );
17+ }
1518 }
1619 runApp (MaterialApp (home: MyApp ()));
1720}
@@ -266,6 +269,8 @@ List<String>? getCmds() {
266269 cmdSuffix = "'" ;
267270 } else if (Platform .isMacOS) {
268271 cmd = 'open' ;
272+ } else if (Platform .isWindows) {
273+ cmd = 'start' ;
269274 } else {
270275 return null ;
271276 }
Original file line number Diff line number Diff line change 55#include " flutter_window.h"
66#include " utils.h"
77
8+ #include < protocol_handler/protocol_handler_plugin.h>
9+
810int APIENTRY wWinMain (_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
911 _In_ wchar_t *command_line, _In_ int show_command) {
12+ HWND hwnd = ::FindWindow (L" FLUTTER_RUNNER_WIN32_WINDOW" , L" uni_links_desktop_example" );
13+ if (hwnd != NULL ) {
14+ DispatchToProtocolHandler (hwnd);
15+
16+ ::ShowWindow (hwnd, SW_NORMAL);
17+ ::SetForegroundWindow (hwnd);
18+ return EXIT_FAILURE;
19+ }
20+
1021 // Attach to console when present (e.g., 'flutter run') or create a
1122 // new console when running with a debugger.
1223 if (!::AttachConsole (ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent ()) {
Original file line number Diff line number Diff line change @@ -9,6 +9,10 @@ void enableUniLinksDesktop() {
99 UniLinksPlatform .instance = UniLinksDesktop ();
1010}
1111
12+ void registerProtocol (String scheme) {
13+ protocolHandler.register (scheme);
14+ }
15+
1216class UniLinksDesktop extends UniLinksPlatform with ProtocolListener {
1317 /// Registers this class as the default instance of [UniLinksDesktop] .
1418 static void registerWith () {
You can’t perform that action at this time.
0 commit comments