service.dart 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. import 'package:flowy_editor/service/render_plugin_service.dart';
  2. import 'package:flowy_editor/service/toolbar_service.dart';
  3. import 'package:flowy_editor/service/selection_service.dart';
  4. import 'package:flutter/material.dart';
  5. class FlowyService {
  6. // selection service
  7. final selectionServiceKey = GlobalKey(debugLabel: 'flowy_selection_service');
  8. FlowySelectionService get selectionService {
  9. assert(selectionServiceKey.currentState != null &&
  10. selectionServiceKey.currentState is FlowySelectionService);
  11. return selectionServiceKey.currentState! as FlowySelectionService;
  12. }
  13. // keyboard service
  14. final keyboardServiceKey = GlobalKey(debugLabel: 'flowy_keyboard_service');
  15. // input service
  16. final inputServiceKey = GlobalKey(debugLabel: 'flowy_input_service');
  17. // render plugin service
  18. late FlowyRenderPlugin renderPluginService;
  19. // toolbar service
  20. final toolbarServiceKey = GlobalKey(debugLabel: 'flowy_toolbar_service');
  21. ToolbarService? get toolbarService {
  22. if (toolbarServiceKey.currentState != null &&
  23. toolbarServiceKey.currentState is ToolbarService) {
  24. return toolbarServiceKey.currentState! as ToolbarService;
  25. }
  26. return null;
  27. }
  28. }