File tree Expand file tree Collapse file tree 6 files changed +36
-0
lines changed Expand file tree Collapse file tree 6 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 1
1
import 'package:flutter/material.dart' ;
2
2
import 'package:bot_toast/bot_toast.dart' ;
3
3
import 'package:protocol_handler/protocol_handler.dart' ;
4
+ import 'package:window_manager/window_manager.dart' ;
4
5
5
6
import './pages/home.dart' ;
6
7
7
8
void main () async {
8
9
WidgetsFlutterBinding .ensureInitialized ();
10
+ await windowManager.ensureInitialized ();
11
+
12
+ windowManager.waitUntilReadyToShow ().then ((_) async {
13
+ await windowManager.setSize (const Size (600 , 400 ));
14
+ await windowManager.center ();
15
+ await windowManager.show ();
16
+ });
9
17
10
18
await protocolHandler.register ('myprotocol' );
11
19
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import 'package:bot_toast/bot_toast.dart';
2
2
import 'package:flutter/material.dart' ;
3
3
import 'package:preference_list/preference_list.dart' ;
4
4
import 'package:protocol_handler/protocol_handler.dart' ;
5
+ import 'package:window_manager/window_manager.dart' ;
5
6
6
7
class HomePage extends StatefulWidget {
7
8
const HomePage ({Key ? key}) : super (key: key);
@@ -11,6 +12,8 @@ class HomePage extends StatefulWidget {
11
12
}
12
13
13
14
class _HomePageState extends State <HomePage > with ProtocolListener {
15
+ bool _isAlwaysOnTop = false ;
16
+
14
17
final List <String > _receivedUrlList = [];
15
18
16
19
@override
@@ -28,6 +31,19 @@ class _HomePageState extends State<HomePage> with ProtocolListener {
28
31
Widget _buildBody (BuildContext context) {
29
32
return PreferenceList (
30
33
children: < Widget > [
34
+ PreferenceListSection (
35
+ children: [
36
+ PreferenceListSwitchItem (
37
+ title: const Text ('setAlwaysOnTop' ),
38
+ value: _isAlwaysOnTop,
39
+ onChanged: (newValue) async {
40
+ _isAlwaysOnTop = newValue;
41
+ await windowManager.setAlwaysOnTop (_isAlwaysOnTop);
42
+ setState (() {});
43
+ },
44
+ ),
45
+ ],
46
+ ),
31
47
PreferenceListSection (
32
48
title: const Text ('Received urls' ),
33
49
children: [
Original file line number Diff line number Diff line change @@ -212,6 +212,13 @@ packages:
212
212
url: "https://pub.dartlang.org"
213
213
source: hosted
214
214
version: "0.1.2"
215
+ window_manager:
216
+ dependency: "direct main"
217
+ description:
218
+ name: window_manager
219
+ url: "https://pub.dartlang.org"
220
+ source: hosted
221
+ version: "0.2.0"
215
222
sdks:
216
223
dart: ">=2.16.1 <3.0.0"
217
224
flutter: ">=2.5.0"
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ dependencies:
28
28
29
29
bot_toast : ^4.0.1
30
30
preference_list : ^0.0.1
31
+ window_manager : ^0.2.0
31
32
32
33
# The following adds the Cupertino Icons font to your application.
33
34
# Use with the CupertinoIcons class for iOS style icons.
Original file line number Diff line number Diff line change 7
7
#include " generated_plugin_registrant.h"
8
8
9
9
#include < protocol_handler/protocol_handler_plugin.h>
10
+ #include < window_manager/window_manager_plugin.h>
10
11
11
12
void RegisterPlugins (flutter::PluginRegistry* registry) {
12
13
ProtocolHandlerPluginRegisterWithRegistrar (
13
14
registry->GetRegistrarForPlugin (" ProtocolHandlerPlugin" ));
15
+ WindowManagerPluginRegisterWithRegistrar (
16
+ registry->GetRegistrarForPlugin (" WindowManagerPlugin" ));
14
17
}
Original file line number Diff line number Diff line change 4
4
5
5
list (APPEND FLUTTER_PLUGIN_LIST
6
6
protocol_handler
7
+ window_manager
7
8
)
8
9
9
10
set (PLUGIN_BUNDLED_LIBRARIES )
You can’t perform that action at this time.
0 commit comments