Files
MWClash/plugins/window_ext/lib/window_ext_manager.dart
chen08209 89bbbc6864 Fix windows tray issues
Fix urltest issues

Add auto changelog
2024-10-12 15:06:55 +08:00

40 lines
998 B
Dart

import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'window_ext_listener.dart';
class WindowExtManager {
WindowExtManager._() {
_channel.setMethodCallHandler(_methodCallHandler);
}
static final WindowExtManager instance = WindowExtManager._();
final MethodChannel _channel = const MethodChannel('window_ext');
final ObserverList<WindowExtListener> _listeners = ObserverList<WindowExtListener>();
Future<void> _methodCallHandler(MethodCall call) async {
for (final WindowExtListener listener in _listeners) {
switch (call.method) {
case "taskbarCreated":
listener.onTaskbarCreated();
break;
}
}
}
bool get hasListeners {
return _listeners.isNotEmpty;
}
void addListener(WindowExtListener listener) {
_listeners.add(listener);
}
void removeListener(WindowExtListener listener) {
_listeners.remove(listener);
}
}
final windowExtManager = WindowExtManager.instance;