Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web Support #2466

Draft
wants to merge 16 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Dart format
Levi-Lesches committed Nov 15, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 086041bee52c40f338fb698722941d73ee57dbf7
Original file line number Diff line number Diff line change
@@ -284,8 +284,8 @@ class FlutterLocalNotificationsPlugin {
/// be canceled. `tag` has no effect on other platforms.
Future<void> cancel(int id, {String? tag}) async {
if (kIsWeb) {
await resolvePlatformSpecificImplementation
<WebFlutterLocalNotificationsPlugin>()
await resolvePlatformSpecificImplementation<
WebFlutterLocalNotificationsPlugin>()
?.cancel(id, tag: tag);
} else if (defaultTargetPlatform == TargetPlatform.android) {
await resolvePlatformSpecificImplementation<
2 changes: 1 addition & 1 deletion flutter_local_notifications/lib/src/web_mock.dart
Original file line number Diff line number Diff line change
@@ -10,5 +10,5 @@ class WebFlutterLocalNotificationsPlugin
Future<bool> requestNotificationsPermission() async => false;

@override
Future<void> cancel(int id, {String? tag}) async { }
Future<void> cancel(int id, {String? tag}) async {}
}
8 changes: 4 additions & 4 deletions flutter_local_notifications/lib/src/web_real.dart
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@ class WebFlutterLocalNotificationsPlugin
final List<ActiveNotification> result = <ActiveNotification>[];
final Set<int> ids = <int>{};
final List<Notification> jsNotifs =
await _registration!.getDartNotifications();
await _registration!.getDartNotifications();
for (final Notification jsNotification in jsNotifs) {
final int? id = jsNotification.id;
if (id == null) {
@@ -67,7 +67,7 @@ class WebFlutterLocalNotificationsPlugin
return;
}
final List<Notification> notifs =
await _registration!.getDartNotifications();
await _registration!.getDartNotifications();
for (final Notification notification in notifs) {
if (notification.id == id || (tag != null && tag == notification.tag)) {
notification.close();
@@ -81,7 +81,7 @@ class WebFlutterLocalNotificationsPlugin
return;
}
final List<Notification> notifs =
await _registration!.getDartNotifications();
await _registration!.getDartNotifications();
for (final Notification notification in notifs) {
notification.close();
}
@@ -95,5 +95,5 @@ extension on Notification {

extension on ServiceWorkerRegistration {
Future<List<Notification>> getDartNotifications() async =>
(await getNotifications().toDart).toDart;
(await getNotifications().toDart).toDart;
}