This commit is contained in:
wyf
2025-11-14 12:01:07 +08:00
parent 776275aa3d
commit 7e44998240
24 changed files with 409 additions and 187 deletions

View File

@@ -0,0 +1,23 @@
import 'dart:async';
class EventBus {
static final EventBus _instance = EventBus._internal();
factory EventBus() => _instance;
EventBus._internal();
final _controller = StreamController.broadcast();
// 发出任意事件
void emit(event) {
_controller.add(event);
}
// 监听指定类型的事件
Stream<T> on<T>() {
return _controller.stream.where((event) => event is T).cast<T>();
}
void dispose() {
_controller.close();
}
}

View File

@@ -0,0 +1,14 @@
class VideoDownloadEvent {
final bool success;
VideoDownloadEvent(this.success);
}
class BleConnectEvent {
final bool connected;
BleConnectEvent(this.connected);
}
class SwitchLanguageEvent {
final String language;
SwitchLanguageEvent(this.language);
}