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 11import 'package:flutter/material.dart' ;
22import 'package:bot_toast/bot_toast.dart' ;
33import 'package:protocol_handler/protocol_handler.dart' ;
4+ import 'package:window_manager/window_manager.dart' ;
45
56import './pages/home.dart' ;
67
78void main () async {
89 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+ });
917
1018 await protocolHandler.register ('myprotocol' );
1119
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import 'package:bot_toast/bot_toast.dart';
22import 'package:flutter/material.dart' ;
33import 'package:preference_list/preference_list.dart' ;
44import 'package:protocol_handler/protocol_handler.dart' ;
5+ import 'package:window_manager/window_manager.dart' ;
56
67class HomePage extends StatefulWidget {
78 const HomePage ({Key ? key}) : super (key: key);
@@ -11,6 +12,8 @@ class HomePage extends StatefulWidget {
1112}
1213
1314class _HomePageState extends State <HomePage > with ProtocolListener {
15+ bool _isAlwaysOnTop = false ;
16+
1417 final List <String > _receivedUrlList = [];
1518
1619 @override
@@ -28,6 +31,19 @@ class _HomePageState extends State<HomePage> with ProtocolListener {
2831 Widget _buildBody (BuildContext context) {
2932 return PreferenceList (
3033 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+ ),
3147 PreferenceListSection (
3248 title: const Text ('Received urls' ),
3349 children: [
Original file line number Diff line number Diff line change @@ -212,6 +212,13 @@ packages:
212212 url: "https://pub.dartlang.org"
213213 source: hosted
214214 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"
215222sdks:
216223 dart: ">=2.16.1 <3.0.0"
217224 flutter: ">=2.5.0"
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ dependencies:
2828
2929 bot_toast : ^4.0.1
3030 preference_list : ^0.0.1
31+ window_manager : ^0.2.0
3132
3233 # The following adds the Cupertino Icons font to your application.
3334 # Use with the CupertinoIcons class for iOS style icons.
Original file line number Diff line number Diff line change 77#include " generated_plugin_registrant.h"
88
99#include < protocol_handler/protocol_handler_plugin.h>
10+ #include < window_manager/window_manager_plugin.h>
1011
1112void RegisterPlugins (flutter::PluginRegistry* registry) {
1213 ProtocolHandlerPluginRegisterWithRegistrar (
1314 registry->GetRegistrarForPlugin (" ProtocolHandlerPlugin" ));
15+ WindowManagerPluginRegisterWithRegistrar (
16+ registry->GetRegistrarForPlugin (" WindowManagerPlugin" ));
1417}
Original file line number Diff line number Diff line change 44
55list (APPEND FLUTTER_PLUGIN_LIST
66 protocol_handler
7+ window_manager
78)
89
910set (PLUGIN_BUNDLED_LIBRARIES)
You can’t perform that action at this time.
0 commit comments