From 8107b2c3c2aa499f1b8c3e83582c44b13401292c Mon Sep 17 00:00:00 2001 From: dab246 Date: Mon, 25 Mar 2024 09:57:57 +0700 Subject: [PATCH 1/3] fix: BroadcastChannel method not found when run on `dart.library.io` --- example/example.dart | 5 +++++ lib/src/html.dart | 1 + lib/src/html/api/broadcast_channel.dart | 13 +++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 lib/src/html/api/broadcast_channel.dart diff --git a/example/example.dart b/example/example.dart index 8aaed10..bfcaedc 100644 --- a/example/example.dart +++ b/example/example.dart @@ -14,4 +14,9 @@ void main() { // Do a CSS query print(divElement.querySelector('div > .greeting')!.text); // --> Hello world + + final broadcastChannel = BroadcastChannel('Channel_Name'); + broadcastChannel.onMessage.listen((event) { + print(event); + }); } diff --git a/lib/src/html.dart b/lib/src/html.dart index 67dc568..17ee5a6 100644 --- a/lib/src/html.dart +++ b/lib/src/html.dart @@ -87,6 +87,7 @@ part 'html/api/web_socket.dart'; part 'html/api/window.dart'; part 'html/api/window_misc.dart'; part 'html/api/workers.dart'; +part 'html/api/broadcast_channel.dart'; part 'html/dom/css.dart'; part 'html/dom/css_computed_style.dart'; part 'html/dom/css_rect.dart'; diff --git a/lib/src/html/api/broadcast_channel.dart b/lib/src/html/api/broadcast_channel.dart new file mode 100644 index 0000000..9840606 --- /dev/null +++ b/lib/src/html/api/broadcast_channel.dart @@ -0,0 +1,13 @@ +part of universal_html.internal; + +class BroadcastChannel { + final String name; + + BroadcastChannel(this.name); + + void close() {} + + void postMessage(Object message) {} + + Stream get onMessage => const Stream.empty(); +} \ No newline at end of file From 3fe467186368cd8ca502e6df005371ea3c9800d5 Mon Sep 17 00:00:00 2001 From: "Teemu S." Date: Sun, 16 Nov 2025 21:35:38 +0000 Subject: [PATCH 2/3] Remove BroadcastChannel code from example.dart Removed BroadcastChannel implementation from example.dart. --- example/example.dart | 5 ----- 1 file changed, 5 deletions(-) diff --git a/example/example.dart b/example/example.dart index f59d88d..6b8cf44 100644 --- a/example/example.dart +++ b/example/example.dart @@ -16,9 +16,4 @@ void main() { // Do a CSS query print(divElement.querySelector('div > .greeting')!.text); // --> Hello world - - final broadcastChannel = BroadcastChannel('Channel_Name'); - broadcastChannel.onMessage.listen((event) { - print(event); - }); } From c8ce1cc1b8374c8007043859e33832114ff6427d Mon Sep 17 00:00:00 2001 From: "Teemu S." Date: Sun, 16 Nov 2025 22:33:19 +0000 Subject: [PATCH 3/3] Update part directive in broadcast_channel.dart --- lib/src/html/api/broadcast_channel.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/html/api/broadcast_channel.dart b/lib/src/html/api/broadcast_channel.dart index 9840606..3bb9114 100644 --- a/lib/src/html/api/broadcast_channel.dart +++ b/lib/src/html/api/broadcast_channel.dart @@ -1,4 +1,4 @@ -part of universal_html.internal; +part of '../../html.dart'; class BroadcastChannel { final String name; @@ -10,4 +10,4 @@ class BroadcastChannel { void postMessage(Object message) {} Stream get onMessage => const Stream.empty(); -} \ No newline at end of file +}