Skip to content

Commit bea7231

Browse files
committed
chore: formatting
1 parent beff4bc commit bea7231

24 files changed

+239
-116
lines changed

example/integration_test/plugin_integration_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
// For more information about Flutter integration tests, please see
77
// https://docs.flutter.dev/cookbook/testing/integration/introduction
88

9-
109
import 'package:flutter_test/flutter_test.dart';
1110
import 'package:integration_test/integration_test.dart';
1211

example/lib/main.dart

Lines changed: 96 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import 'package:flutter/material.dart';
21
import 'dart:async';
32
//ignore: avoid_web_libraries_in_flutter
43
import 'dart:html' as html;
54

5+
import 'package:flutter/foundation.dart';
6+
import 'package:flutter/material.dart';
67
import 'package:js_notifications/interop/interop.dart';
78
import 'package:js_notifications/js_notifications_web.dart';
89
import 'package:js_notifications/platform_interface/js_notifications_platform_interface.dart';
9-
import 'package:js_notifications/utils/utils.dart';
1010
import 'package:stop_watch_timer/stop_watch_timer.dart';
1111

1212
void main() {
@@ -61,77 +61,94 @@ class _MyAppState extends State<MyApp> {
6161
}
6262
case "confused":
6363
{
64-
_sendBasicNotification("Go watch Star Wars, now!", tag: "star_wars_channel");
64+
_sendBasicNotification("Go watch Star Wars, now!",
65+
tag: "star_wars_channel");
6566
break;
6667
}
6768
case "kill_him":
6869
{
69-
_sendBasicNotification("Good good, now go watch Star Wars!", tag: "star_wars_channel");
70+
_sendBasicNotification("Good good, now go watch Star Wars!",
71+
tag: "star_wars_channel");
7072
break;
7173
}
7274
case "watch_star_wars":
7375
{
74-
_sendBasicNotification("Sure, click here to watch it.", tag: "rick_roll");
76+
_sendBasicNotification("Sure, click here to watch it.",
77+
tag: "rick_roll");
7578
break;
7679
}
7780

78-
case _notificationActionStopwatchStart: {
79-
_startTimerNotification();
80-
break;
81-
}
81+
case _notificationActionStopwatchStart:
82+
{
83+
_startTimerNotification();
84+
break;
85+
}
8286

83-
case _notificationActionStopwatchPause: {
84-
_pauseTimerNotification();
85-
_onSecondTimerTick();
86-
break;
87-
}
87+
case _notificationActionStopwatchPause:
88+
{
89+
_pauseTimerNotification();
90+
_onSecondTimerTick();
91+
break;
92+
}
8893

89-
case _notificationActionStopwatchStop: {
90-
_stopTimerNotification();
91-
_onSecondTimerTick();
92-
break;
93-
}
94+
case _notificationActionStopwatchStop:
95+
{
96+
_stopTimerNotification();
97+
_onSecondTimerTick();
98+
break;
99+
}
94100

95-
case _notificationActionStopwatchSilent: {
96-
setState(() {
97-
_stopwatchSilent = true;
98-
});
99-
break;
100-
}
101+
case _notificationActionStopwatchSilent:
102+
{
103+
setState(() {
104+
_stopwatchSilent = true;
105+
});
106+
break;
107+
}
101108

102-
case _notificationActionStopwatchHeadsUp: {
103-
setState(() {
104-
_stopwatchSilent = false;
105-
});
106-
break;
107-
}
109+
case _notificationActionStopwatchHeadsUp:
110+
{
111+
setState(() {
112+
_stopwatchSilent = false;
113+
});
114+
break;
115+
}
108116

109-
default: {
110-
if(event.tag == "rick_roll") {
111-
openNewWindow("https://www.youtube.com/watch?v=dQw4w9WgXcQ");
112-
} else if(event.tag == "star_wars_channel") {
113-
openNewWindow("https://www.youtube.com/@StarWars");
117+
default:
118+
{
119+
if (event.tag == "rick_roll") {
120+
openNewWindow("https://www.youtube.com/watch?v=dQw4w9WgXcQ");
121+
} else if (event.tag == "star_wars_channel") {
122+
openNewWindow("https://www.youtube.com/@StarWars");
123+
}
114124
}
115-
}
116125
}
117126
});
118127
_jsNotificationsPlugin.dismissStream.listen((event) {
119-
switch(event.tag) {
120-
case "data-notification": {
121-
_sendBasicNotification("Dismissed data notification", tag: "");
122-
break;
123-
}
124-
case "grievous": {
125-
_sendBasicNotification("My disappointment is immeasurable and my day is ruined.", tag: "ruined");
126-
break;
127-
}
128+
switch (event.tag) {
129+
case "data-notification":
130+
{
131+
_sendBasicNotification("Dismissed data notification", tag: "");
132+
break;
133+
}
134+
case "grievous":
135+
{
136+
_sendBasicNotification(
137+
"My disappointment is immeasurable and my day is ruined.",
138+
tag: "ruined");
139+
break;
140+
}
128141
}
129142
});
130143
}
131144

132145
void _onSecondTimerTick() {
133-
final formattedCallTime = StopWatchTimer.getDisplayTime(stopWatchTimer.rawTime.value, milliSecond: false);
134-
printDebug("Timer: $formattedCallTime");
146+
final formattedCallTime = StopWatchTimer.getDisplayTime(
147+
stopWatchTimer.rawTime.value,
148+
milliSecond: false);
149+
if (kDebugMode) {
150+
print("Timer: $formattedCallTime");
151+
}
135152
_jsNotificationsPlugin.showNotification(
136153
"Timer",
137154
body: formattedCallTime,
@@ -142,16 +159,22 @@ class _MyAppState extends State<MyApp> {
142159
silent: _stopwatchSilent,
143160
actions: [
144161
if (stopWatchTimer.isRunning) ...[
145-
const JSNotificationAction(action: _notificationActionStopwatchPause, title: "Pause"),
146-
const JSNotificationAction(action: _notificationActionStopwatchStop, title: "Stop"),
162+
const JSNotificationAction(
163+
action: _notificationActionStopwatchPause, title: "Pause"),
164+
const JSNotificationAction(
165+
action: _notificationActionStopwatchStop, title: "Stop"),
147166
] else ...[
148-
const JSNotificationAction(action: _notificationActionStopwatchStart, title: "Start"),
149-
const JSNotificationAction(action: _notificationActionDismiss, title: "Dismiss"),
167+
const JSNotificationAction(
168+
action: _notificationActionStopwatchStart, title: "Start"),
169+
const JSNotificationAction(
170+
action: _notificationActionDismiss, title: "Dismiss"),
150171
],
151172
if (_stopwatchSilent)
152-
const JSNotificationAction(action: _notificationActionStopwatchHeadsUp, title: "Heads Up")
173+
const JSNotificationAction(
174+
action: _notificationActionStopwatchHeadsUp, title: "Heads Up")
153175
else
154-
const JSNotificationAction(action: _notificationActionStopwatchSilent, title: "Silence"),
176+
const JSNotificationAction(
177+
action: _notificationActionStopwatchSilent, title: "Silence"),
155178
],
156179
);
157180
}
@@ -175,7 +198,8 @@ class _MyAppState extends State<MyApp> {
175198
children: [
176199
ElevatedButton(
177200
onPressed: () {
178-
_sendBasicNotification("Test Notification", tag: "test");
201+
_sendBasicNotification("Test Notification",
202+
tag: "test");
179203
},
180204
child: const Text("Test Notification"),
181205
),
@@ -285,7 +309,8 @@ class _MyAppState extends State<MyApp> {
285309
);
286310
}
287311

288-
Future<void> _sendDataNotification({String? id, String? title, String? body, Map<String, dynamic>? data}) {
312+
Future<void> _sendDataNotification(
313+
{String? id, String? title, String? body, Map<String, dynamic>? data}) {
289314
final id0 = id ?? "data-notification";
290315
final title0 = title ?? "Data Notification";
291316
final body0 = body ?? "A notification with some data too";
@@ -297,10 +322,11 @@ class _MyAppState extends State<MyApp> {
297322
'c': 'c',
298323
'[]': [],
299324
'{}': {},
300-
if(data != null) ...data,
325+
if (data != null) ...data,
301326
};
302327

303-
return _jsNotificationsPlugin.showNotification(title0, body: body0, data: data0, tag: id0);
328+
return _jsNotificationsPlugin.showNotification(title0,
329+
body: body0, data: data0, tag: id0);
304330
}
305331

306332
Future<void> _sendBasicNotification(String title, {String? tag}) {
@@ -314,12 +340,14 @@ class _MyAppState extends State<MyApp> {
314340
Future<void> _sendSpanishInquisition() {
315341
return _jsNotificationsPlugin.showNotification(
316342
"Oh no!",
317-
body: "Subverted expectations result in expected unexpected expectations. Anyway, check the icon...",
343+
body:
344+
"Subverted expectations result in expected unexpected expectations. Anyway, check the icon...",
318345
tag: "inquisition",
319346
icon: "https://pbs.twimg.com/media/CtCG_f4WcAAJY-1.jpg",
320347
actions: [
321348
const JSNotificationAction(action: "dismiss", title: "Whatever"),
322-
const JSNotificationAction(action: "unexpected", title: "Didn't expect that"),
349+
const JSNotificationAction(
350+
action: "unexpected", title: "Didn't expect that"),
323351
],
324352
requireInteraction: true,
325353
);
@@ -333,7 +361,8 @@ class _MyAppState extends State<MyApp> {
333361
icon:
334362
"https://www.liveabout.com/thmb/F5lfgFptU9DNTDCT-xNEtot0lQ0=/1500x0/filters:no_upscale():max_bytes(150000):strip_icc()/EP2-IA-60435_R_8x10-56a83bea3df78cf7729d314a.jpg",
335363
actions: [
336-
const JSNotificationAction(action: "general_kenobi", title: "General Kenobi"),
364+
const JSNotificationAction(
365+
action: "general_kenobi", title: "General Kenobi"),
337366
const JSNotificationAction(action: "confused", title: "I'm confused"),
338367
],
339368
requireInteraction: true,
@@ -345,10 +374,12 @@ class _MyAppState extends State<MyApp> {
345374
"Grievous",
346375
tag: "grievous_2",
347376
body: "You acknowledge he is a bold one. What do you do?",
348-
icon: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQvS2A_Sb7z7dXcrPVscT0FeCdFO7IM88U2vg&s",
377+
icon:
378+
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQvS2A_Sb7z7dXcrPVscT0FeCdFO7IM88U2vg&s",
349379
actions: [
350380
const JSNotificationAction(action: "kill_him", title: "Kill Him"),
351-
const JSNotificationAction(action: "watch_star_wars", title: "Watch Star Wars"),
381+
const JSNotificationAction(
382+
action: "watch_star_wars", title: "Watch Star Wars"),
352383
],
353384
requireInteraction: true,
354385
);
@@ -375,7 +406,8 @@ class _MyAppState extends State<MyApp> {
375406
}
376407

377408
void _startTimerNotification() {
378-
_stopWatchTimerListener ??= stopWatchTimer.secondTime.listen((_) => _onSecondTimerTick());
409+
_stopWatchTimerListener ??=
410+
stopWatchTimer.secondTime.listen((_) => _onSecondTimerTick());
379411
_stopwatchSilent = false;
380412
stopWatchTimer.onStartTimer();
381413
}

example/pubspec.lock

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ packages:
4141
url: "https://pub.dev"
4242
source: hosted
4343
version: "1.18.0"
44+
crypto:
45+
dependency: transitive
46+
description:
47+
name: crypto
48+
sha256: "1e445881f28f22d6140f181e07737b22f1e099a5e1ff94b0af2f9e4a463f4855"
49+
url: "https://pub.dev"
50+
source: hosted
51+
version: "3.0.6"
4452
cupertino_icons:
4553
dependency: "direct main"
4654
description:
@@ -65,6 +73,14 @@ packages:
6573
url: "https://pub.dev"
6674
source: hosted
6775
version: "7.0.0"
76+
fixnum:
77+
dependency: transitive
78+
description:
79+
name: fixnum
80+
sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be
81+
url: "https://pub.dev"
82+
source: hosted
83+
version: "1.1.1"
6884
flutter:
6985
dependency: "direct main"
7086
description: flutter
@@ -109,7 +125,7 @@ packages:
109125
path: ".."
110126
relative: true
111127
source: path
112-
version: "0.0.1"
128+
version: "0.0.2"
113129
leak_tracker:
114130
dependency: transitive
115131
description:
@@ -206,6 +222,14 @@ packages:
206222
url: "https://pub.dev"
207223
source: hosted
208224
version: "0.28.0"
225+
simple_print:
226+
dependency: transitive
227+
description:
228+
name: simple_print
229+
sha256: "49b6796fb93b557bbba4eca687b8521d3d20ffee47d74d8a0857f6ee0727042b"
230+
url: "https://pub.dev"
231+
source: hosted
232+
version: "0.0.1+2"
209233
sky_engine:
210234
dependency: transitive
211235
description: flutter
@@ -219,6 +243,14 @@ packages:
219243
url: "https://pub.dev"
220244
source: hosted
221245
version: "1.10.0"
246+
sprintf:
247+
dependency: transitive
248+
description:
249+
name: sprintf
250+
sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23"
251+
url: "https://pub.dev"
252+
source: hosted
253+
version: "7.0.0"
222254
stack_trace:
223255
dependency: transitive
224256
description:
@@ -275,6 +307,22 @@ packages:
275307
url: "https://pub.dev"
276308
source: hosted
277309
version: "0.7.0"
310+
typed_data:
311+
dependency: transitive
312+
description:
313+
name: typed_data
314+
sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
315+
url: "https://pub.dev"
316+
source: hosted
317+
version: "1.3.2"
318+
uuid:
319+
dependency: transitive
320+
description:
321+
name: uuid
322+
sha256: a5be9ef6618a7ac1e964353ef476418026db906c4facdedaa299b7a2e71690ff
323+
url: "https://pub.dev"
324+
source: hosted
325+
version: "4.5.1"
278326
vector_math:
279327
dependency: transitive
280328
description:

example/test/widget_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ void main() {
1818
// Verify that platform version is retrieved.
1919
expect(
2020
find.byWidgetPredicate(
21-
(Widget widget) => widget is Text &&
22-
widget.data!.startsWith('Running on:'),
21+
(Widget widget) =>
22+
widget is Text && widget.data!.startsWith('Running on:'),
2323
),
2424
findsOneWidget,
2525
);

lib/const/const.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
const String jsNotificationsSwJs = "js_notifications-sw.js";
2-
const String defaultScope = "/js_notifications/";
2+
const String defaultScope = "/js_notifications/";

lib/const/sw_events.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ class SWEvents {
2121

2222
/// See: https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API/Using_the_Notifications_API#close
2323
static const String close = "close";
24-
}
24+
}

0 commit comments

Comments
 (0)