Skip to content

Commit 0843d78

Browse files
committed
0.1.0
1 parent 443b6cb commit 0843d78

File tree

5 files changed

+218
-15
lines changed

5 files changed

+218
-15
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
## 0.0.1
1+
## 0.1.0
22

3-
* TODO: Describe initial release.
3+
* First release.

LICENSE

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,21 @@
1-
TODO: Add your license here.
1+
MIT License
2+
3+
Copyright (c) 2022 LiJianying <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 192 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,198 @@
11
# uni_links_desktop
22

3-
A new flutter plugin project.
3+
[![pub version][pub-image]][pub-url] [![][discord-image]][discord-url]
44

5-
## Getting Started
5+
[pub-image]: https://img.shields.io/pub/v/uni_links_desktop.svg
6+
[pub-url]: https://pub.dev/packages/uni_links_desktop
67

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.
8+
[discord-image]: https://img.shields.io/discord/884679008049037342.svg
9+
[discord-url]: https://discord.gg/zPa6EZ2jqb
1110

12-
For help getting started with Flutter, view our
13-
[online documentation](https://flutter.dev/docs), which offers tutorials,
14-
samples, guidance on mobile development, and a full API reference.
11+
A desktop (supports macOS and Windows) implementation of [uni_links](https://github.com/leanflutter/uni_links_desktop) plugin.
1512

13+
---
14+
15+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
16+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
17+
18+
- [uni_links_desktop](#uni_links_desktop)
19+
- [Platform Support](#platform-support)
20+
- [Quick Start](#quick-start)
21+
- [Installation](#installation)
22+
- [Usage](#usage)
23+
- [macOS](#macos)
24+
- [Windows](#windows)
25+
- [Who's using it?](#whos-using-it)
26+
- [License](#license)
27+
28+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
29+
30+
## Platform Support
31+
32+
| Linux | macOS | Windows |
33+
| :---: | :---: | :-----: |
34+
|| ✔️ | ✔️ |
35+
36+
## Quick Start
37+
38+
### Installation
39+
40+
Add this to your package's pubspec.yaml file:
41+
42+
```yaml
43+
dependencies:
44+
uni_links_desktop: ^0.1.1
45+
```
46+
47+
Or
48+
49+
```yaml
50+
dependencies:
51+
uni_links_desktop:
52+
git:
53+
url: https://github.com/leanflutter/uni_links_desktop.git
54+
ref: main
55+
```
56+
57+
### Usage
58+
59+
```dart
60+
import 'package:uni_links_desktop/uni_links_desktop.dart';
61+
62+
void main() {
63+
if (Platform.isMacOS || Platform.isWindows) {
64+
enableUniLinksDesktop();
65+
if (Platform.isWindows) {
66+
registerProtocol('unilinks');
67+
}
68+
}
69+
70+
runApp(MyApp());
71+
}
72+
```
73+
74+
> Just add these extra steps, see [uni_links](https://github.com/avioli/uni_links/tree/master/uni_links) for other usage
75+
76+
##### macOS
77+
78+
Change the file `macos/Runner/Info.plist` as follows:
79+
80+
```diff
81+
<?xml version="1.0" encoding="UTF-8"?>
82+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
83+
<plist version="1.0">
84+
<dict>
85+
<key>CFBundleDevelopmentRegion</key>
86+
<string>$(DEVELOPMENT_LANGUAGE)</string>
87+
<key>CFBundleExecutable</key>
88+
<string>$(EXECUTABLE_NAME)</string>
89+
<key>CFBundleIconFile</key>
90+
<string></string>
91+
<key>CFBundleIdentifier</key>
92+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
93+
<key>CFBundleInfoDictionaryVersion</key>
94+
<string>6.0</string>
95+
<key>CFBundleName</key>
96+
<string>$(PRODUCT_NAME)</string>
97+
<key>CFBundlePackageType</key>
98+
<string>APPL</string>
99+
<key>CFBundleShortVersionString</key>
100+
<string>$(FLUTTER_BUILD_NAME)</string>
101+
<key>CFBundleVersion</key>
102+
<string>$(FLUTTER_BUILD_NUMBER)</string>
103+
<key>LSMinimumSystemVersion</key>
104+
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
105+
<key>NSHumanReadableCopyright</key>
106+
<string>$(PRODUCT_COPYRIGHT)</string>
107+
<key>NSMainNibFile</key>
108+
<string>MainMenu</string>
109+
+ <key>CFBundleURLTypes</key>
110+
+ <array>
111+
+ <dict>
112+
+ <key>CFBundleTypeRole</key>
113+
+ <string>Editor</string>
114+
+ <key>CFBundleURLName</key>
115+
+ <string></string>
116+
+ <key>CFBundleURLSchemes</key>
117+
+ <array>
118+
+ <string>unilinks</string>
119+
+ </array>
120+
+ </dict>
121+
+ </array>
122+
<key>NSPrincipalClass</key>
123+
<string>NSApplication</string>
124+
</dict>
125+
</plist>
126+
}
127+
```
128+
129+
##### Windows
130+
131+
Change the file `windows/runner/main.cpp` as follows:
132+
133+
```diff
134+
#include <flutter/dart_project.h>
135+
#include <flutter/flutter_view_controller.h>
136+
#include <windows.h>
137+
138+
#include "flutter_window.h"
139+
#include "utils.h"
140+
141+
+#include <protocol_handler/protocol_handler_plugin.h>
142+
143+
int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
144+
_In_ wchar_t *command_line, _In_ int show_command) {
145+
+ HWND hwnd = ::FindWindow(L"FLUTTER_RUNNER_WIN32_WINDOW", L"uni_links_desktop_example");
146+
+ if (hwnd != NULL) {
147+
+ DispatchToProtocolHandler(hwnd);
148+
+
149+
+ ::ShowWindow(hwnd, SW_NORMAL);
150+
+ ::SetForegroundWindow(hwnd);
151+
+ return EXIT_FAILURE;
152+
+ }
153+
154+
// Attach to console when present (e.g., 'flutter run') or create a
155+
// new console when running with a debugger.
156+
if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
157+
CreateAndAttachConsole();
158+
}
159+
160+
// Initialize COM, so that it is available for use in the library and/or
161+
// plugins.
162+
::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
163+
164+
flutter::DartProject project(L"data");
165+
166+
std::vector<std::string> command_line_arguments =
167+
GetCommandLineArguments();
168+
169+
project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
170+
171+
FlutterWindow window(project);
172+
Win32Window::Point origin(10, 10);
173+
Win32Window::Size size(1280, 720);
174+
if (!window.CreateAndShow(L"uni_links_desktop_example", origin, size)) {
175+
return EXIT_FAILURE;
176+
}
177+
window.SetQuitOnClose(true);
178+
179+
::MSG msg;
180+
while (::GetMessage(&msg, nullptr, 0, 0)) {
181+
::TranslateMessage(&msg);
182+
::DispatchMessage(&msg);
183+
}
184+
185+
::CoUninitialize();
186+
return EXIT_SUCCESS;
187+
}
188+
```
189+
190+
> Please see the example app of this plugin for a full example.
191+
192+
## Who's using it?
193+
194+
- [Biyi](https://biyidev.com/) - A convenient translation and dictionary app.
195+
196+
## License
197+
198+
[MIT](./LICENSE)

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ packages:
209209
path: ".."
210210
relative: true
211211
source: path
212-
version: "0.0.1"
212+
version: "0.1.0"
213213
uni_links_platform_interface:
214214
dependency: transitive
215215
description:

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: uni_links_desktop
2-
description: A new flutter plugin project.
3-
version: 0.0.1
2+
description: A desktop (supports macOS and Windows) implementation of uni_links plugin.
3+
version: 0.1.0
44
homepage: https://github.com/leanflutter/uni_links_desktop
55

66
platforms:

0 commit comments

Comments
 (0)