Skip to content

Commit 8107b2c

Browse files
committed
fix: BroadcastChannel method not found when run on dart.library.io
1 parent 45116f0 commit 8107b2c

3 files changed

Lines changed: 19 additions & 0 deletions

File tree

example/example.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,9 @@ void main() {
1414
// Do a CSS query
1515
print(divElement.querySelector('div > .greeting')!.text);
1616
// --> Hello world
17+
18+
final broadcastChannel = BroadcastChannel('Channel_Name');
19+
broadcastChannel.onMessage.listen((event) {
20+
print(event);
21+
});
1722
}

lib/src/html.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ part 'html/api/web_socket.dart';
8787
part 'html/api/window.dart';
8888
part 'html/api/window_misc.dart';
8989
part 'html/api/workers.dart';
90+
part 'html/api/broadcast_channel.dart';
9091
part 'html/dom/css.dart';
9192
part 'html/dom/css_computed_style.dart';
9293
part 'html/dom/css_rect.dart';
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
part of universal_html.internal;
2+
3+
class BroadcastChannel {
4+
final String name;
5+
6+
BroadcastChannel(this.name);
7+
8+
void close() {}
9+
10+
void postMessage(Object message) {}
11+
12+
Stream<dynamic> get onMessage => const Stream.empty();
13+
}

0 commit comments

Comments
 (0)