app_window.dart 894 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import 'dart:ui';
  2. import 'package:app_flowy/core/helpers/helpers.dart';
  3. import 'package:flutter/foundation.dart';
  4. import 'package:window_manager/window_manager.dart';
  5. /// Represents the main window of the app.
  6. class AppWindow {
  7. /// The singleton instance of the window.
  8. static late AppWindow instance;
  9. AppWindow._() {
  10. instance = this;
  11. }
  12. /// Initializes the window.
  13. static Future<AppWindow?> initialize() async {
  14. // Don't initialize on mobile or web.
  15. if (!defaultTargetPlatform.isDesktop) {
  16. return null;
  17. }
  18. await windowManager.ensureInitialized();
  19. WindowOptions windowOptions = const WindowOptions(
  20. minimumSize: Size(600, 400),
  21. title: 'AppFlowy',
  22. );
  23. await windowManager.waitUntilReadyToShow(windowOptions, () async {
  24. await windowManager.show();
  25. await windowManager.focus();
  26. });
  27. return AppWindow._();
  28. }
  29. }