# uni_links_desktop **Repository Path**: leanflutter/uni_links_desktop ## Basic Information - **Project Name**: uni_links_desktop - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-03-21 - **Last Updated**: 2024-02-06 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # uni_links_desktop [![pub version][pub-image]][pub-url] [![][discord-image]][discord-url] [pub-image]: https://img.shields.io/pub/v/uni_links_desktop.svg [pub-url]: https://pub.dev/packages/uni_links_desktop [discord-image]: https://img.shields.io/discord/884679008049037342.svg [discord-url]: https://discord.gg/zPa6EZ2jqb A desktop (supports macOS and Windows) implementation of [uni_links](https://pub.dev/packages/uni_links) plugin. --- - [uni_links_desktop](#uni_links_desktop) - [Platform Support](#platform-support) - [Quick Start](#quick-start) - [Installation](#installation) - [Usage](#usage) - [macOS](#macos) - [Windows](#windows) - [Who's using it?](#whos-using-it) - [License](#license) ## Platform Support | Linux | macOS | Windows | | :---: | :---: | :-----: | | ➖ | ✔️ | ✔️ | ## Quick Start ### Installation Add this to your package's pubspec.yaml file: ```yaml dependencies: uni_links_desktop: ^0.1.7 ``` Or ```yaml dependencies: uni_links_desktop: git: url: https://github.com/leanflutter/uni_links_desktop.git ref: main ``` ### Usage ```dart import 'package:uni_links_desktop/uni_links_desktop.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); if (Platform.isWindows) { registerProtocol('unilinks'); } runApp(const MaterialApp( home: MyApp(), )); } ``` > Just add these extra steps, see [uni_links](https://github.com/avioli/uni_links/tree/master/uni_links) for other usage ##### macOS Change the file `macos/Runner/Info.plist` as follows: ```diff CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIconFile CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName $(PRODUCT_NAME) CFBundlePackageType APPL CFBundleShortVersionString $(FLUTTER_BUILD_NAME) CFBundleVersion $(FLUTTER_BUILD_NUMBER) LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) NSHumanReadableCopyright $(PRODUCT_COPYRIGHT) NSMainNibFile MainMenu + CFBundleURLTypes + + + CFBundleTypeRole + Editor + CFBundleURLName + + CFBundleURLSchemes + + unilinks + + + NSPrincipalClass NSApplication ``` ##### Windows Change the file `windows/runner/main.cpp` as follows: ```diff #include #include #include #include "flutter_window.h" #include "utils.h" +#include int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, _In_ wchar_t *command_line, _In_ int show_command) { + // Replace uni_links_desktop_example with your_window_title. + HWND hwnd = ::FindWindow(L"FLUTTER_RUNNER_WIN32_WINDOW", L"uni_links_desktop_example"); + if (hwnd != NULL) { + DispatchToUniLinksDesktop(hwnd); + + ::ShowWindow(hwnd, SW_NORMAL); + ::SetForegroundWindow(hwnd); + return EXIT_FAILURE; + } // Attach to console when present (e.g., 'flutter run') or create a // new console when running with a debugger. if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { CreateAndAttachConsole(); } // Initialize COM, so that it is available for use in the library and/or // plugins. ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); flutter::DartProject project(L"data"); std::vector command_line_arguments = GetCommandLineArguments(); project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); FlutterWindow window(project); Win32Window::Point origin(10, 10); Win32Window::Size size(1280, 720); if (!window.CreateAndShow(L"uni_links_desktop_example", origin, size)) { return EXIT_FAILURE; } window.SetQuitOnClose(true); ::MSG msg; while (::GetMessage(&msg, nullptr, 0, 0)) { ::TranslateMessage(&msg); ::DispatchMessage(&msg); } ::CoUninitialize(); return EXIT_SUCCESS; } ``` If you use `MSIX` to package your application, you need to add `protocol_activation` configuration in `msix_config`: ```yaml msix_config: protocol_activation: myprotocol ``` > See this issue for details: [YehudaKremer/msix#187](https://github.com/YehudaKremer/msix/issues/187) > Please see the example app of this plugin for a full example. ## Who's using it? - [Biyi](https://biyidev.com/) - A convenient translation and dictionary app. ## License [MIT](./LICENSE)