Skip to content

Commit 0486388

Browse files
committed
Update example
1 parent 23edd91 commit 0486388

File tree

6 files changed

+36
-0
lines changed

6 files changed

+36
-0
lines changed

example/lib/main.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
import 'package:flutter/material.dart';
22
import 'package:bot_toast/bot_toast.dart';
33
import 'package:protocol_handler/protocol_handler.dart';
4+
import 'package:window_manager/window_manager.dart';
45

56
import './pages/home.dart';
67

78
void 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

example/lib/pages/home.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:bot_toast/bot_toast.dart';
22
import 'package:flutter/material.dart';
33
import 'package:preference_list/preference_list.dart';
44
import 'package:protocol_handler/protocol_handler.dart';
5+
import 'package:window_manager/window_manager.dart';
56

67
class HomePage extends StatefulWidget {
78
const HomePage({Key? key}) : super(key: key);
@@ -11,6 +12,8 @@ class HomePage extends StatefulWidget {
1112
}
1213

1314
class _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: [

example/pubspec.lock

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff 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"
215222
sdks:
216223
dart: ">=2.16.1 <3.0.0"
217224
flutter: ">=2.5.0"

example/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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.

example/windows/flutter/generated_plugin_registrant.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77
#include "generated_plugin_registrant.h"
88

99
#include <protocol_handler/protocol_handler_plugin.h>
10+
#include <window_manager/window_manager_plugin.h>
1011

1112
void RegisterPlugins(flutter::PluginRegistry* registry) {
1213
ProtocolHandlerPluginRegisterWithRegistrar(
1314
registry->GetRegistrarForPlugin("ProtocolHandlerPlugin"));
15+
WindowManagerPluginRegisterWithRegistrar(
16+
registry->GetRegistrarForPlugin("WindowManagerPlugin"));
1417
}

example/windows/flutter/generated_plugins.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
list(APPEND FLUTTER_PLUGIN_LIST
66
protocol_handler
7+
window_manager
78
)
89

910
set(PLUGIN_BUNDLED_LIBRARIES)

0 commit comments

Comments
 (0)