platform_channel.dart 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import 'package:flutter/foundation.dart';
  2. import 'package:flutter/services.dart';
  3. import 'package:flutter_hbb/main.dart';
  4. import 'package:flutter_hbb/common.dart';
  5. enum SystemWindowTheme { light, dark }
  6. /// The platform channel for RustDesk.
  7. class RdPlatformChannel {
  8. RdPlatformChannel._();
  9. static final RdPlatformChannel _windowUtil = RdPlatformChannel._();
  10. static RdPlatformChannel get instance => _windowUtil;
  11. final MethodChannel _osxMethodChannel =
  12. MethodChannel("org.rustdesk.rustdesk/macos");
  13. /// Change the theme of the system window
  14. Future<void> changeSystemWindowTheme(SystemWindowTheme theme) {
  15. assert(isMacOS);
  16. if (kDebugMode) {
  17. print(
  18. "[Window ${kWindowId ?? 'Main'}] change system window theme to ${theme.name}");
  19. }
  20. return _osxMethodChannel
  21. .invokeMethod("setWindowTheme", {"themeName": theme.name});
  22. }
  23. /// Terminate .app manually.
  24. Future<void> terminate() {
  25. assert(isMacOS);
  26. return _osxMethodChannel.invokeMethod("terminate");
  27. }
  28. }