Skip to content

Commit 377b704

Browse files
committed
Updates minimum supported SDK version to Flutter 3.3/Dart 3.0.
1 parent 38e58ba commit 377b704

File tree

16 files changed

+222
-192
lines changed

16 files changed

+222
-192
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.2.2
2+
3+
* fix(linux): ensure icon works in sandboxed environments #43
4+
* Updates minimum supported SDK version to Flutter 3.3/Dart 3.0.
5+
16
## 0.2.1
27

38
* chore: Bump flutter to 3.6

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022-2023 LiJianying <[email protected]>
3+
Copyright (c) 2022-2024 LiJianying <[email protected]>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include: package:mostly_reasonable_lints/flutter.yaml

example/analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include: package:mostly_reasonable_lints/flutter.yaml

example/lib/main.dart

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
1-
import 'package:flutter/material.dart';
21
import 'package:bot_toast/bot_toast.dart';
3-
4-
import './pages/home.dart';
2+
import 'package:flutter/material.dart';
3+
import 'package:tray_manager_example/pages/home.dart';
54

65
void main() {
76
WidgetsFlutterBinding.ensureInitialized();
87

9-
runApp(MyApp());
8+
runApp(const MyApp());
109
}
1110

1211
class MyApp extends StatefulWidget {
12+
const MyApp({super.key});
13+
1314
@override
14-
_MyAppState createState() => _MyAppState();
15+
State<MyApp> createState() => _MyAppState();
1516
}
1617

1718
class _MyAppState extends State<MyApp> {
1819
@override
1920
Widget build(BuildContext context) {
2021
return MaterialApp(
2122
theme: ThemeData(
22-
primaryColor: Color(0xff416ff4),
23+
primaryColor: const Color(0xff416ff4),
2324
canvasColor: Colors.white,
24-
scaffoldBackgroundColor: Color(0xffF7F9FB),
25+
scaffoldBackgroundColor: const Color(0xffF7F9FB),
2526
dividerColor: Colors.grey.withOpacity(0.3),
2627
),
2728
builder: BotToastInit(),
2829
navigatorObservers: [BotToastNavigatorObserver()],
29-
home: HomePage(),
30+
home: const HomePage(),
3031
);
3132
}
3233
}

example/lib/pages/home.dart

Lines changed: 64 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@ import 'dart:async';
22
import 'dart:io';
33

44
import 'package:bot_toast/bot_toast.dart';
5-
import 'package:flutter/cupertino.dart' hide MenuItem;
6-
import 'package:flutter/material.dart' hide MenuItem;
5+
import 'package:flutter/cupertino.dart';
6+
import 'package:flutter/foundation.dart';
7+
import 'package:flutter/material.dart';
78
import 'package:preference_list/preference_list.dart';
89
import 'package:tray_manager/tray_manager.dart';
910

1011
const _kIconTypeDefault = 'default';
1112
const _kIconTypeOriginal = 'original';
1213

1314
class HomePage extends StatefulWidget {
15+
const HomePage({super.key});
16+
1417
@override
15-
_HomePageState createState() => _HomePageState();
18+
State<HomePage> createState() => _HomePageState();
1619
}
1720

1821
class _HomePageState extends State<HomePage> with TrayListener {
@@ -33,7 +36,7 @@ class _HomePageState extends State<HomePage> with TrayListener {
3336
super.dispose();
3437
}
3538

36-
void _handleSetIcon(String iconType) async {
39+
Future<void> _handleSetIcon(String iconType) async {
3740
_iconType = iconType;
3841
String iconPath =
3942
Platform.isWindows ? 'images/tray_icon.ico' : 'images/tray_icon.png';
@@ -48,10 +51,12 @@ class _HomePageState extends State<HomePage> with TrayListener {
4851
}
4952

5053
void _startIconFlashing() {
51-
_timer = Timer.periodic(Duration(seconds: 1), (timer) async {
52-
_handleSetIcon(_iconType == _kIconTypeOriginal
53-
? _kIconTypeDefault
54-
: _kIconTypeOriginal);
54+
_timer = Timer.periodic(const Duration(seconds: 1), (timer) async {
55+
_handleSetIcon(
56+
_iconType == _kIconTypeOriginal
57+
? _kIconTypeDefault
58+
: _kIconTypeOriginal,
59+
);
5560
});
5661
setState(() {});
5762
}
@@ -69,48 +74,51 @@ class _HomePageState extends State<HomePage> with TrayListener {
6974
PreferenceListSection(
7075
children: [
7176
PreferenceListItem(
72-
title: Text('destroy'),
77+
title: const Text('destroy'),
7378
onTap: () {
7479
trayManager.destroy();
7580
},
7681
),
7782
PreferenceListItem(
78-
title: Text('setIcon'),
83+
title: const Text('setIcon'),
7984
accessoryView: Row(
8085
children: [
81-
Builder(builder: (_) {
82-
bool isFlashing = (_timer != null && _timer!.isActive);
83-
return CupertinoButton(
84-
child:
85-
isFlashing ? Text('stop flash') : Text('start flash'),
86-
onPressed:
87-
isFlashing ? _stopIconFlashing : _startIconFlashing,
88-
);
89-
}),
86+
Builder(
87+
builder: (_) {
88+
bool isFlashing = (_timer != null && _timer!.isActive);
89+
return CupertinoButton(
90+
onPressed:
91+
isFlashing ? _stopIconFlashing : _startIconFlashing,
92+
child: isFlashing
93+
? const Text('stop flash')
94+
: const Text('start flash'),
95+
);
96+
},
97+
),
9098
CupertinoButton(
91-
child: Text('Default'),
99+
child: const Text('Default'),
92100
onPressed: () => _handleSetIcon(_kIconTypeDefault),
93101
),
94102
CupertinoButton(
95-
child: Text('Original'),
103+
child: const Text('Original'),
96104
onPressed: () => _handleSetIcon(_kIconTypeOriginal),
97105
),
98106
],
99107
),
100108
onTap: () => _handleSetIcon(_kIconTypeDefault),
101109
),
102110
PreferenceListItem(
103-
title: Text('setIconPosition'),
111+
title: const Text('setIconPosition'),
104112
accessoryView: Row(
105113
children: [
106114
CupertinoButton(
107-
child: Text('left'),
115+
child: const Text('left'),
108116
onPressed: () {
109117
trayManager.setIconPosition(TrayIconPositon.left);
110118
},
111119
),
112120
CupertinoButton(
113-
child: Text('right'),
121+
child: const Text('right'),
114122
onPressed: () {
115123
trayManager.setIconPosition(TrayIconPositon.right);
116124
},
@@ -120,19 +128,19 @@ class _HomePageState extends State<HomePage> with TrayListener {
120128
onTap: () => _handleSetIcon(_kIconTypeDefault),
121129
),
122130
PreferenceListItem(
123-
title: Text('setToolTip'),
131+
title: const Text('setToolTip'),
124132
onTap: () async {
125133
await trayManager.setToolTip('tray_manager');
126134
},
127135
),
128136
PreferenceListItem(
129-
title: Text('setTitle'),
137+
title: const Text('setTitle'),
130138
onTap: () async {
131139
await trayManager.setTitle('tray_manager');
132140
},
133141
),
134142
PreferenceListItem(
135-
title: Text('setContextMenu'),
143+
title: const Text('setContextMenu'),
136144
onTap: () async {
137145
_menu ??= Menu(
138146
items: [
@@ -161,15 +169,19 @@ class _HomePageState extends State<HomePage> with TrayListener {
161169
label: 'Item 1',
162170
checked: true,
163171
onClick: (menuItem) {
164-
print('click item 1');
172+
if (kDebugMode) {
173+
print('click item 1');
174+
}
165175
menuItem.checked = !(menuItem.checked == true);
166176
},
167177
),
168178
MenuItem.checkbox(
169179
label: 'Item 2',
170180
checked: false,
171181
onClick: (menuItem) {
172-
print('click item 2');
182+
if (kDebugMode) {
183+
print('click item 2');
184+
}
173185
menuItem.checked = !(menuItem.checked == true);
174186
},
175187
),
@@ -185,15 +197,19 @@ class _HomePageState extends State<HomePage> with TrayListener {
185197
label: 'Item 1',
186198
checked: true,
187199
onClick: (menuItem) {
188-
print('click item 1');
200+
if (kDebugMode) {
201+
print('click item 1');
202+
}
189203
menuItem.checked = !(menuItem.checked == true);
190204
},
191205
),
192206
MenuItem.checkbox(
193207
label: 'Item 2',
194208
checked: false,
195209
onClick: (menuItem) {
196-
print('click item 2');
210+
if (kDebugMode) {
211+
print('click item 2');
212+
}
197213
menuItem.checked = !(menuItem.checked == true);
198214
},
199215
),
@@ -232,13 +248,13 @@ class _HomePageState extends State<HomePage> with TrayListener {
232248
},
233249
),
234250
PreferenceListItem(
235-
title: Text('popUpContextMenu'),
251+
title: const Text('popUpContextMenu'),
236252
onTap: () async {
237253
await trayManager.popUpContextMenu();
238254
},
239255
),
240256
PreferenceListItem(
241-
title: Text('getBounds'),
257+
title: const Text('getBounds'),
242258
onTap: () async {
243259
Rect? bounds = await trayManager.getBounds();
244260
if (bounds != null) {
@@ -268,29 +284,39 @@ class _HomePageState extends State<HomePage> with TrayListener {
268284

269285
@override
270286
void onTrayIconMouseDown() {
271-
print('onTrayIconMouseDown');
287+
if (kDebugMode) {
288+
print('onTrayIconMouseDown');
289+
}
272290
trayManager.popUpContextMenu();
273291
}
274292

275293
@override
276294
void onTrayIconMouseUp() {
277-
print('onTrayIconMouseUp');
295+
if (kDebugMode) {
296+
print('onTrayIconMouseUp');
297+
}
278298
}
279299

280300
@override
281301
void onTrayIconRightMouseDown() {
282-
print('onTrayIconRightMouseDown');
302+
if (kDebugMode) {
303+
print('onTrayIconRightMouseDown');
304+
}
283305
// trayManager.popUpContextMenu();
284306
}
285307

286308
@override
287309
void onTrayIconRightMouseUp() {
288-
print('onTrayIconRightMouseUp');
310+
if (kDebugMode) {
311+
print('onTrayIconRightMouseUp');
312+
}
289313
}
290314

291315
@override
292316
void onTrayMenuItemClick(MenuItem menuItem) {
293-
print(menuItem.toJson());
317+
if (kDebugMode) {
318+
print(menuItem.toJson());
319+
}
294320
BotToast.showText(
295321
text: '${menuItem.toJson()}',
296322
);

example/macos/Runner.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@
203203
isa = PBXProject;
204204
attributes = {
205205
LastSwiftUpdateCheck = 0920;
206-
LastUpgradeCheck = 1430;
206+
LastUpgradeCheck = 1510;
207207
ORGANIZATIONNAME = "";
208208
TargetAttributes = {
209209
33CC10EC2044A3C60003C045 = {

example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1430"
3+
LastUpgradeVersion = "1510"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

0 commit comments

Comments
 (0)