├── .github
├── FUNDING.yml
└── workflows
│ ├── build.yml
│ └── lint.yml
├── .gitignore
├── .idea
├── libraries
│ └── Dart_SDK.xml
├── modules.xml
├── runConfigurations
│ └── example_lib_main_dart.xml
└── workspace.xml
├── .metadata
├── CHANGELOG.md
├── LICENSE
├── README-ZH.md
├── README.md
├── analysis_options.yaml
├── dart_dependency_validator.yaml
├── example
├── .gitignore
├── .metadata
├── README.md
├── analysis_options.yaml
├── lib
│ ├── main.dart
│ └── pages
│ │ └── home.dart
├── linux
│ ├── .gitignore
│ ├── CMakeLists.txt
│ ├── flutter
│ │ ├── CMakeLists.txt
│ │ ├── generated_plugin_registrant.cc
│ │ ├── generated_plugin_registrant.h
│ │ └── generated_plugins.cmake
│ ├── main.cc
│ ├── my_application.cc
│ └── my_application.h
├── macos
│ ├── .gitignore
│ ├── Flutter
│ │ ├── Flutter-Debug.xcconfig
│ │ ├── Flutter-Release.xcconfig
│ │ └── GeneratedPluginRegistrant.swift
│ ├── Podfile
│ ├── Podfile.lock
│ ├── Runner.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ └── xcshareddata
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ └── Runner.xcscheme
│ ├── Runner.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ └── Runner
│ │ ├── AppDelegate.swift
│ │ ├── Assets.xcassets
│ │ └── AppIcon.appiconset
│ │ │ ├── Contents.json
│ │ │ ├── app_icon_1024.png
│ │ │ ├── app_icon_128.png
│ │ │ ├── app_icon_16.png
│ │ │ ├── app_icon_256.png
│ │ │ ├── app_icon_32.png
│ │ │ ├── app_icon_512.png
│ │ │ └── app_icon_64.png
│ │ ├── Base.lproj
│ │ └── MainMenu.xib
│ │ ├── Configs
│ │ ├── AppInfo.xcconfig
│ │ ├── Debug.xcconfig
│ │ ├── Release.xcconfig
│ │ └── Warnings.xcconfig
│ │ ├── DebugProfile.entitlements
│ │ ├── Info.plist
│ │ ├── MainFlutterWindow.swift
│ │ └── Release.entitlements
├── pubspec.lock
├── pubspec.yaml
├── test
│ └── widget_test.dart
└── windows
│ ├── .gitignore
│ ├── CMakeLists.txt
│ ├── flutter
│ ├── CMakeLists.txt
│ ├── generated_plugin_registrant.cc
│ ├── generated_plugin_registrant.h
│ └── generated_plugins.cmake
│ └── runner
│ ├── CMakeLists.txt
│ ├── Runner.rc
│ ├── flutter_window.cpp
│ ├── flutter_window.h
│ ├── main.cpp
│ ├── resource.h
│ ├── resources
│ └── app_icon.ico
│ ├── run_loop.cpp
│ ├── run_loop.h
│ ├── runner.exe.manifest
│ ├── utils.cpp
│ ├── utils.h
│ ├── win32_window.cpp
│ └── win32_window.h
├── lib
├── screen_text_extractor.dart
└── src
│ ├── clipboard_once_watcher.dart
│ ├── extract_mode.dart
│ ├── extracted_data.dart
│ └── screen_text_extractor.dart
├── linux
├── CMakeLists.txt
├── include
│ └── screen_text_extractor
│ │ └── screen_text_extractor_plugin.h
└── screen_text_extractor_plugin.cc
├── macos
├── Classes
│ └── ScreenTextExtractorPlugin.swift
└── screen_text_extractor.podspec
├── pubspec.lock
├── pubspec.yaml
├── screen_text_extractor.iml
├── test
└── screen_text_extractor_test.dart
└── windows
├── .clang-format
├── .gitignore
├── CMakeLists.txt
├── include
└── screen_text_extractor
│ └── screen_text_extractor_plugin.h
└── screen_text_extractor_plugin.cpp
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | liberapay: lijy91
2 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: build
2 |
3 | on:
4 | push:
5 | branches: [main]
6 | pull_request:
7 | branches: [main]
8 |
9 | jobs:
10 | # build-linux:
11 | # runs-on: ubuntu-latest
12 | # steps:
13 | # - uses: actions/checkout@v2
14 | # - uses: subosito/flutter-action@v2
15 | # - run: |
16 | # sudo apt-get update -y
17 | # sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev
18 | # - run: flutter config --enable-linux-desktop
19 | # - run: cd example && flutter build linux -v
20 | build-macos:
21 | runs-on: macos-latest
22 | steps:
23 | - uses: actions/checkout@v2
24 | - uses: subosito/flutter-action@v2
25 | - run: flutter config --enable-macos-desktop
26 | - run: cd example && flutter build macos -v
27 | build-windows:
28 | runs-on: windows-latest
29 | steps:
30 | - uses: actions/checkout@v2
31 | - uses: subosito/flutter-action@v2
32 | - run: cd example && flutter build windows -v
33 |
--------------------------------------------------------------------------------
/.github/workflows/lint.yml:
--------------------------------------------------------------------------------
1 | name: lint
2 |
3 | on:
4 | push:
5 | branches: [main]
6 | pull_request:
7 | branches: [main]
8 |
9 | jobs:
10 | analyze:
11 | runs-on: ubuntu-latest
12 | steps:
13 | - uses: actions/checkout@v3
14 | - uses: subosito/flutter-action@v2
15 | with:
16 | channel: "stable"
17 | - run: flutter analyze --fatal-infos
18 |
19 | format:
20 | runs-on: ubuntu-latest
21 | steps:
22 | - uses: actions/checkout@v3
23 | - uses: subosito/flutter-action@v2
24 | with:
25 | channel: "stable"
26 | - run: dart format . --fix --set-exit-if-changed
27 |
28 | dependency_validator:
29 | runs-on: ubuntu-latest
30 | steps:
31 | - uses: actions/checkout@v3
32 | - uses: subosito/flutter-action@v2
33 | with:
34 | channel: "stable"
35 | - run: flutter pub get
36 | - run: flutter pub run dependency_validator
37 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .dart_tool/
3 |
4 | .packages
5 | .pub/
6 |
7 | build/
8 |
--------------------------------------------------------------------------------
/.idea/libraries/Dart_SDK.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/example_lib_main_dart.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: f4abaa0735eba4dfd8f33f73363911d63931fe03
8 | channel: stable
9 |
10 | project_type: plugin
11 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## 0.1.3
2 |
3 | * chore: bump flutter 3.10.0 & bump clipboard_watcher to 0.2.0
4 |
5 | ## 0.1.2
6 |
7 | * Recovery `isAccessAllowed` and `requestAccess` methods
8 |
9 | ## 0.1.1
10 |
11 | * [macos] Remove implementation via accessibility api
12 | * [macos] Support sandbox mode
13 | * Replace the `extractFromClipboard`, `extractFromScreenSelection` methods with the `extract` method
14 |
15 | ## 0.1.0
16 |
17 | * First release.
18 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021-2023 LiJianying
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/README-ZH.md:
--------------------------------------------------------------------------------
1 | > **🚀 快速发布您的应用**: 试试 [Fastforge](https://fastforge.dev) - 构建、打包和分发您的 Flutter 应用最简单的方式。
2 |
3 | # screen_text_extractor
4 |
5 | [![pub version][pub-image]][pub-url] [![][discord-image]][discord-url] ![][visits-count-image]
6 |
7 | [pub-image]: https://img.shields.io/pub/v/screen_text_extractor.svg
8 | [pub-url]: https://pub.dev/packages/screen_text_extractor
9 |
10 | [discord-image]: https://img.shields.io/discord/884679008049037342.svg
11 | [discord-url]: https://discord.gg/zPa6EZ2jqb
12 |
13 | [visits-count-image]: https://img.shields.io/badge/dynamic/json?label=Visits%20Count&query=value&url=https://api.countapi.xyz/hit/leanflutter.screen_text_extractor/visits
14 |
15 | 这个插件允许 Flutter 桌面应用从屏幕上提取文本。
16 |
17 | ---
18 |
19 | [English](./README.md) | 简体中文
20 |
21 | ---
22 |
23 |
24 |
25 |
26 | - [screen_text_extractor](#screen_text_extractor)
27 | - [平台支持](#平台支持)
28 | - [快速开始](#快速开始)
29 | - [安装](#安装)
30 | - [用法](#用法)
31 | - [谁在用使用它?](#谁在用使用它)
32 | - [API](#api)
33 | - [ScreenTextExtractor](#screentextextractor)
34 | - [许可证](#许可证)
35 |
36 |
37 |
38 | ## 平台支持
39 |
40 | | Linux | macOS | Windows |
41 | | :---: | :---: | :-----: |
42 | | ✔️ | ✔️ | ✔️ |
43 |
44 | ## 快速开始
45 |
46 | ### 安装
47 |
48 | 将此添加到你的软件包的 pubspec.yaml 文件:
49 |
50 | ```yaml
51 | dependencies:
52 | screen_text_extractor: ^0.1.3
53 | ```
54 |
55 | 或
56 |
57 | ```yaml
58 | dependencies:
59 | screen_text_extractor:
60 | git:
61 | url: https://github.com/leanflutter/screen_text_extractor.git
62 | ref: main
63 | ```
64 |
65 | ### 用法
66 |
67 | ```dart
68 | import 'package:screen_text_extractor/screen_text_extractor.dart';
69 |
70 | ExtractedData data;
71 |
72 | data = await ScreenTextExtractor.instance.extractFromClipboard();
73 | data = await ScreenTextExtractor.instance.extractFromScreenSelection();
74 | ```
75 |
76 | > 请看这个插件的示例应用,以了解完整的例子。
77 |
78 | ## 谁在用使用它?
79 |
80 | - [Biyi (比译)](https://biyidev.com/) - 一个便捷的翻译和词典应用。
81 |
82 | ## API
83 |
84 | ### ScreenTextExtractor
85 |
86 | | Method | Description | Linux | MacOS | Windows |
87 | | -------------------------- | ------------ | ----- | ----- | ------- |
88 | | isAccessAllowed | `macOS` only | ➖ | ✔️ | ➖ |
89 | | requestAccess | `macOS` only | ➖ | ✔️ | ➖ |
90 | | extractFromClipboard | | ✔️ | ✔️ | ✔️ |
91 | | extractFromScreenSelection | | ✔️ | ✔️ | ✔️ |
92 |
93 | ## 许可证
94 |
95 | [MIT](./LICENSE)
96 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | > **🚀 Ship Your App Faster**: Try [Fastforge](https://fastforge.dev) - The simplest way to build, package and distribute your Flutter apps.
2 |
3 | # screen_text_extractor
4 |
5 | [![pub version][pub-image]][pub-url] [![][discord-image]][discord-url] ![][visits-count-image]
6 |
7 | [pub-image]: https://img.shields.io/pub/v/screen_text_extractor.svg
8 | [pub-url]: https://pub.dev/packages/screen_text_extractor
9 |
10 | [discord-image]: https://img.shields.io/discord/884679008049037342.svg
11 | [discord-url]: https://discord.gg/zPa6EZ2jqb
12 |
13 | [visits-count-image]: https://img.shields.io/badge/dynamic/json?label=Visits%20Count&query=value&url=https://api.countapi.xyz/hit/leanflutter.screen_text_extractor/visits
14 |
15 | This plugin allows Flutter desktop apps to extract text from screen.
16 |
17 | ---
18 |
19 | English | [简体中文](./README-ZH.md)
20 |
21 | ---
22 |
23 |
24 |
25 |
26 | - [screen_text_extractor](#screen_text_extractor)
27 | - [Platform Support](#platform-support)
28 | - [Quick Start](#quick-start)
29 | - [Installation](#installation)
30 | - [Usage](#usage)
31 | - [Who's using it?](#whos-using-it)
32 | - [API](#api)
33 | - [ScreenTextExtractor](#screentextextractor)
34 | - [License](#license)
35 |
36 |
37 |
38 | ## Platform Support
39 |
40 | | Linux | macOS | Windows |
41 | | :---: | :---: | :-----: |
42 | | ✔️ | ✔️ | ✔️ |
43 |
44 | ## Quick Start
45 |
46 | ### Installation
47 |
48 | Add this to your package's pubspec.yaml file:
49 |
50 | ```yaml
51 | dependencies:
52 | screen_text_extractor: ^0.1.3
53 | ```
54 |
55 | Or
56 |
57 | ```yaml
58 | dependencies:
59 | screen_text_extractor:
60 | git:
61 | url: https://github.com/leanflutter/screen_text_extractor.git
62 | ref: main
63 | ```
64 |
65 | ### Usage
66 |
67 | ```dart
68 | import 'package:screen_text_extractor/screen_text_extractor.dart';
69 |
70 | ExtractedData data;
71 |
72 | data = await ScreenTextExtractor.instance.extractFromClipboard();
73 | data = await ScreenTextExtractor.instance.extractFromScreenSelection();
74 | ```
75 |
76 | > Please see the example app of this plugin for a full example.
77 |
78 | ## Who's using it?
79 |
80 | - [Biyi (比译)](https://biyidev.com/) - A convenient translation and dictionary app.
81 |
82 | ## API
83 |
84 | ### ScreenTextExtractor
85 |
86 | | Method | Description | Linux | MacOS | Windows |
87 | | -------------------------- | ------------ | ----- | ----- | ------- |
88 | | isAccessAllowed | `macOS` only | ➖ | ✔️ | ➖ |
89 | | requestAccess | `macOS` only | ➖ | ✔️ | ➖ |
90 | | extractFromClipboard | | ✔️ | ✔️ | ✔️ |
91 | | extractFromScreenSelection | | ✔️ | ✔️ | ✔️ |
92 |
93 | ## License
94 |
95 | [MIT](./LICENSE)
96 |
--------------------------------------------------------------------------------
/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | include: package:flutter_lints/flutter.yaml
2 |
3 | # Additional information about this file can be found at
4 | # https://dart.dev/guides/language/analysis-options
5 |
--------------------------------------------------------------------------------
/dart_dependency_validator.yaml:
--------------------------------------------------------------------------------
1 | exclude:
2 | - "example/**"
3 |
--------------------------------------------------------------------------------
/example/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 |
12 | # IntelliJ related
13 | *.iml
14 | *.ipr
15 | *.iws
16 | .idea/
17 |
18 | # The .vscode folder contains launch configuration and tasks you configure in
19 | # VS Code which you may wish to be included in version control, so this line
20 | # is commented out by default.
21 | #.vscode/
22 |
23 | # Flutter/Dart/Pub related
24 | **/doc/api/
25 | **/ios/Flutter/.last_build_id
26 | .dart_tool/
27 | .flutter-plugins
28 | .flutter-plugins-dependencies
29 | .packages
30 | .pub-cache/
31 | .pub/
32 | /build/
33 |
34 | # Web related
35 | lib/generated_plugin_registrant.dart
36 |
37 | # Symbolication related
38 | app.*.symbols
39 |
40 | # Obfuscation related
41 | app.*.map.json
42 |
43 | # Android Studio will place build artifacts here
44 | /android/app/debug
45 | /android/app/profile
46 | /android/app/release
47 |
--------------------------------------------------------------------------------
/example/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: f4abaa0735eba4dfd8f33f73363911d63931fe03
8 | channel: stable
9 |
10 | project_type: app
11 |
--------------------------------------------------------------------------------
/example/README.md:
--------------------------------------------------------------------------------
1 | # screen_text_extractor_example
2 |
3 | Demonstrates how to use the screen_text_extractor plugin.
4 |
5 | ## Getting Started
6 |
7 | This project is a starting point for a Flutter application.
8 |
9 | A few resources to get you started if this is your first Flutter project:
10 |
11 | - [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
13 |
14 | For help getting started with Flutter, view our
15 | [online documentation](https://flutter.dev/docs), which offers tutorials,
16 | samples, guidance on mobile development, and a full API reference.
17 |
--------------------------------------------------------------------------------
/example/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | # This file configures the analyzer, which statically analyzes Dart code to
2 | # check for errors, warnings, and lints.
3 | #
4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6 | # invoked from the command line by running `flutter analyze`.
7 |
8 | # The following line activates a set of recommended lints for Flutter apps,
9 | # packages, and plugins designed to encourage good coding practices.
10 | include: package:flutter_lints/flutter.yaml
11 |
12 | linter:
13 | # The lint rules applied to this project can be customized in the
14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml`
15 | # included above or to enable additional rules. A list of all available lints
16 | # and their documentation is published at
17 | # https://dart-lang.github.io/linter/lints/index.html.
18 | #
19 | # Instead of disabling a lint rule for the entire project in the
20 | # section below, it can also be suppressed for a single line of code
21 | # or a specific dart file by using the `// ignore: name_of_lint` and
22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file
23 | # producing the lint.
24 | rules:
25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule
26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
27 |
28 | # Additional information about this file can be found at
29 | # https://dart.dev/guides/language/analysis-options
30 |
--------------------------------------------------------------------------------
/example/lib/main.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:bot_toast/bot_toast.dart';
3 |
4 | import './pages/home.dart';
5 |
6 | void main() {
7 | WidgetsFlutterBinding.ensureInitialized();
8 |
9 | runApp(const MyApp());
10 | }
11 |
12 | class MyApp extends StatefulWidget {
13 | const MyApp({Key? key}) : super(key: key);
14 |
15 | @override
16 | State createState() => _MyAppState();
17 | }
18 |
19 | class _MyAppState extends State {
20 | @override
21 | Widget build(BuildContext context) {
22 | return MaterialApp(
23 | theme: ThemeData(
24 | primaryColor: const Color(0xff416ff4),
25 | canvasColor: Colors.white,
26 | scaffoldBackgroundColor: const Color(0xffF7F9FB),
27 | dividerColor: Colors.grey.withOpacity(0.3),
28 | ),
29 | builder: BotToastInit(),
30 | navigatorObservers: [BotToastNavigatorObserver()],
31 | home: const HomePage(),
32 | );
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/example/lib/pages/home.dart:
--------------------------------------------------------------------------------
1 | // ignore_for_file: avoid_print
2 |
3 | import 'package:bot_toast/bot_toast.dart';
4 | import 'package:flutter/material.dart';
5 | import 'package:hotkey_manager/hotkey_manager.dart';
6 | import 'package:preference_list/preference_list.dart';
7 | import 'package:screen_text_extractor/screen_text_extractor.dart';
8 |
9 | final hotKeyManager = HotKeyManager.instance;
10 | final screenTextExtractor = ScreenTextExtractor.instance;
11 |
12 | final kShortcutExtractFromClipboard =
13 | HotKey(KeyCode.keyZ, modifiers: [KeyModifier.alt]);
14 | final kShortcutExtractFromScreenSelection =
15 | HotKey(KeyCode.keyX, modifiers: [KeyModifier.alt]);
16 |
17 | class HomePage extends StatefulWidget {
18 | const HomePage({Key? key}) : super(key: key);
19 |
20 | @override
21 | State createState() => _HomePageState();
22 | }
23 |
24 | class _HomePageState extends State {
25 | @override
26 | void initState() {
27 | super.initState();
28 | _init();
29 | }
30 |
31 | void _init() async {
32 | // 初始化快捷键
33 | hotKeyManager.unregisterAll();
34 | hotKeyManager.register(
35 | kShortcutExtractFromClipboard,
36 | keyDownHandler: (_) {
37 | _handleExtractTextFromClipboard();
38 | },
39 | );
40 | hotKeyManager.register(
41 | kShortcutExtractFromScreenSelection,
42 | keyDownHandler: (_) {
43 | _handleExtractTextFromScreenSelection();
44 | },
45 | );
46 |
47 | setState(() {});
48 | }
49 |
50 | void _handleExtractTextFromClipboard() async {
51 | print('_handleExtractTextFromClipboard');
52 | ExtractedData? extractedData = await screenTextExtractor.extract(
53 | mode: ExtractMode.clipboard,
54 | );
55 | print(extractedData?.toJson());
56 | BotToast.showText(text: 'extractedData: ${extractedData?.toJson()}');
57 | }
58 |
59 | void _handleExtractTextFromScreenSelection() async {
60 | print('_handleExtractTextFromScreenSelection');
61 | ExtractedData? extractedData = await screenTextExtractor.extract(
62 | mode: ExtractMode.screenSelection,
63 | );
64 | print(extractedData?.toJson());
65 | BotToast.showText(text: 'extractedData: ${extractedData?.toJson()}');
66 | }
67 |
68 | Widget _buildBody(BuildContext context) {
69 | return PreferenceList(
70 | children: [
71 | PreferenceListSection(
72 | title: const Text('METHODS'),
73 | children: [
74 | PreferenceListItem(
75 | title: const Text('extractTextFromClipboard'),
76 | detailText: Text(kShortcutExtractFromClipboard.toString()),
77 | ),
78 | PreferenceListItem(
79 | title: const Text('extractTextFromScreenSelection'),
80 | detailText: Text(kShortcutExtractFromScreenSelection.toString()),
81 | ),
82 | ],
83 | ),
84 | ],
85 | );
86 | }
87 |
88 | @override
89 | Widget build(BuildContext context) {
90 | return Scaffold(
91 | appBar: AppBar(
92 | title: const Text('Plugin example app'),
93 | ),
94 | body: _buildBody(context),
95 | );
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/example/linux/.gitignore:
--------------------------------------------------------------------------------
1 | flutter/ephemeral
2 |
--------------------------------------------------------------------------------
/example/linux/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10)
2 | project(runner LANGUAGES CXX)
3 |
4 | set(BINARY_NAME "screen_text_extractor_example")
5 | set(APPLICATION_ID "com.example.screen_text_extractor")
6 |
7 | cmake_policy(SET CMP0063 NEW)
8 |
9 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
10 |
11 | # Root filesystem for cross-building.
12 | if(FLUTTER_TARGET_PLATFORM_SYSROOT)
13 | set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT})
14 | set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
15 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
16 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
17 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
18 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
19 | endif()
20 |
21 | # Configure build options.
22 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
23 | set(CMAKE_BUILD_TYPE "Debug" CACHE
24 | STRING "Flutter build mode" FORCE)
25 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
26 | "Debug" "Profile" "Release")
27 | endif()
28 |
29 | # Compilation settings that should be applied to most targets.
30 | function(APPLY_STANDARD_SETTINGS TARGET)
31 | target_compile_features(${TARGET} PUBLIC cxx_std_14)
32 | target_compile_options(${TARGET} PRIVATE -Wall -Werror)
33 | target_compile_options(${TARGET} PRIVATE "$<$>:-O3>")
34 | target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>")
35 | endfunction()
36 |
37 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
38 |
39 | # Flutter library and tool build rules.
40 | add_subdirectory(${FLUTTER_MANAGED_DIR})
41 |
42 | # System-level dependencies.
43 | find_package(PkgConfig REQUIRED)
44 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
45 |
46 | add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
47 |
48 | # Application build
49 | add_executable(${BINARY_NAME}
50 | "main.cc"
51 | "my_application.cc"
52 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
53 | )
54 | apply_standard_settings(${BINARY_NAME})
55 | target_link_libraries(${BINARY_NAME} PRIVATE flutter)
56 | target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
57 | add_dependencies(${BINARY_NAME} flutter_assemble)
58 | # Only the install-generated bundle's copy of the executable will launch
59 | # correctly, since the resources must in the right relative locations. To avoid
60 | # people trying to run the unbundled copy, put it in a subdirectory instead of
61 | # the default top-level location.
62 | set_target_properties(${BINARY_NAME}
63 | PROPERTIES
64 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
65 | )
66 |
67 | # Generated plugin build rules, which manage building the plugins and adding
68 | # them to the application.
69 | include(flutter/generated_plugins.cmake)
70 |
71 |
72 | # === Installation ===
73 | # By default, "installing" just makes a relocatable bundle in the build
74 | # directory.
75 | set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
76 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
77 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
78 | endif()
79 |
80 | # Start with a clean build bundle directory every time.
81 | install(CODE "
82 | file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\")
83 | " COMPONENT Runtime)
84 |
85 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
86 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
87 |
88 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
89 | COMPONENT Runtime)
90 |
91 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
92 | COMPONENT Runtime)
93 |
94 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
95 | COMPONENT Runtime)
96 |
97 | if(PLUGIN_BUNDLED_LIBRARIES)
98 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
99 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
100 | COMPONENT Runtime)
101 | endif()
102 |
103 | # Fully re-copy the assets directory on each build to avoid having stale files
104 | # from a previous install.
105 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
106 | install(CODE "
107 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
108 | " COMPONENT Runtime)
109 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
110 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
111 |
112 | # Install the AOT library on non-Debug builds only.
113 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
114 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
115 | COMPONENT Runtime)
116 | endif()
117 |
--------------------------------------------------------------------------------
/example/linux/flutter/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10)
2 |
3 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
4 |
5 | # Configuration provided via flutter tool.
6 | include(${EPHEMERAL_DIR}/generated_config.cmake)
7 |
8 | # TODO: Move the rest of this into files in ephemeral. See
9 | # https://github.com/flutter/flutter/issues/57146.
10 |
11 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...),
12 | # which isn't available in 3.10.
13 | function(list_prepend LIST_NAME PREFIX)
14 | set(NEW_LIST "")
15 | foreach(element ${${LIST_NAME}})
16 | list(APPEND NEW_LIST "${PREFIX}${element}")
17 | endforeach(element)
18 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE)
19 | endfunction()
20 |
21 | # === Flutter Library ===
22 | # System-level dependencies.
23 | find_package(PkgConfig REQUIRED)
24 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
25 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
26 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
27 |
28 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so")
29 |
30 | # Published to parent scope for install step.
31 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
32 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
33 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
34 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE)
35 |
36 | list(APPEND FLUTTER_LIBRARY_HEADERS
37 | "fl_basic_message_channel.h"
38 | "fl_binary_codec.h"
39 | "fl_binary_messenger.h"
40 | "fl_dart_project.h"
41 | "fl_engine.h"
42 | "fl_json_message_codec.h"
43 | "fl_json_method_codec.h"
44 | "fl_message_codec.h"
45 | "fl_method_call.h"
46 | "fl_method_channel.h"
47 | "fl_method_codec.h"
48 | "fl_method_response.h"
49 | "fl_plugin_registrar.h"
50 | "fl_plugin_registry.h"
51 | "fl_standard_message_codec.h"
52 | "fl_standard_method_codec.h"
53 | "fl_string_codec.h"
54 | "fl_value.h"
55 | "fl_view.h"
56 | "flutter_linux.h"
57 | )
58 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/")
59 | add_library(flutter INTERFACE)
60 | target_include_directories(flutter INTERFACE
61 | "${EPHEMERAL_DIR}"
62 | )
63 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
64 | target_link_libraries(flutter INTERFACE
65 | PkgConfig::GTK
66 | PkgConfig::GLIB
67 | PkgConfig::GIO
68 | )
69 | add_dependencies(flutter flutter_assemble)
70 |
71 | # === Flutter tool backend ===
72 | # _phony_ is a non-existent file to force this command to run every time,
73 | # since currently there's no way to get a full input/output list from the
74 | # flutter tool.
75 | add_custom_command(
76 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
77 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_
78 | COMMAND ${CMAKE_COMMAND} -E env
79 | ${FLUTTER_TOOL_ENVIRONMENT}
80 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
81 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE}
82 | VERBATIM
83 | )
84 | add_custom_target(flutter_assemble DEPENDS
85 | "${FLUTTER_LIBRARY}"
86 | ${FLUTTER_LIBRARY_HEADERS}
87 | )
88 |
--------------------------------------------------------------------------------
/example/linux/flutter/generated_plugin_registrant.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #include "generated_plugin_registrant.h"
8 |
9 | #include
10 | #include
11 | #include
12 |
13 | void fl_register_plugins(FlPluginRegistry* registry) {
14 | g_autoptr(FlPluginRegistrar) clipboard_watcher_registrar =
15 | fl_plugin_registry_get_registrar_for_plugin(registry, "ClipboardWatcherPlugin");
16 | clipboard_watcher_plugin_register_with_registrar(clipboard_watcher_registrar);
17 | g_autoptr(FlPluginRegistrar) hotkey_manager_registrar =
18 | fl_plugin_registry_get_registrar_for_plugin(registry, "HotkeyManagerPlugin");
19 | hotkey_manager_plugin_register_with_registrar(hotkey_manager_registrar);
20 | g_autoptr(FlPluginRegistrar) screen_text_extractor_registrar =
21 | fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenTextExtractorPlugin");
22 | screen_text_extractor_plugin_register_with_registrar(screen_text_extractor_registrar);
23 | }
24 |
--------------------------------------------------------------------------------
/example/linux/flutter/generated_plugin_registrant.h:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #ifndef GENERATED_PLUGIN_REGISTRANT_
8 | #define GENERATED_PLUGIN_REGISTRANT_
9 |
10 | #include
11 |
12 | // Registers Flutter plugins.
13 | void fl_register_plugins(FlPluginRegistry* registry);
14 |
15 | #endif // GENERATED_PLUGIN_REGISTRANT_
16 |
--------------------------------------------------------------------------------
/example/linux/flutter/generated_plugins.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Generated file, do not edit.
3 | #
4 |
5 | list(APPEND FLUTTER_PLUGIN_LIST
6 | clipboard_watcher
7 | hotkey_manager
8 | screen_text_extractor
9 | )
10 |
11 | list(APPEND FLUTTER_FFI_PLUGIN_LIST
12 | )
13 |
14 | set(PLUGIN_BUNDLED_LIBRARIES)
15 |
16 | foreach(plugin ${FLUTTER_PLUGIN_LIST})
17 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
18 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
19 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $)
20 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
21 | endforeach(plugin)
22 |
23 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
24 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
25 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
26 | endforeach(ffi_plugin)
27 |
--------------------------------------------------------------------------------
/example/linux/main.cc:
--------------------------------------------------------------------------------
1 | #include "my_application.h"
2 |
3 | int main(int argc, char** argv) {
4 | g_autoptr(MyApplication) app = my_application_new();
5 | return g_application_run(G_APPLICATION(app), argc, argv);
6 | }
7 |
--------------------------------------------------------------------------------
/example/linux/my_application.cc:
--------------------------------------------------------------------------------
1 | #include "my_application.h"
2 |
3 | #include
4 | #ifdef GDK_WINDOWING_X11
5 | #include
6 | #endif
7 |
8 | #include "flutter/generated_plugin_registrant.h"
9 |
10 | struct _MyApplication {
11 | GtkApplication parent_instance;
12 | char** dart_entrypoint_arguments;
13 | };
14 |
15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
16 |
17 | // Implements GApplication::activate.
18 | static void my_application_activate(GApplication* application) {
19 | MyApplication* self = MY_APPLICATION(application);
20 | GtkWindow* window =
21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
22 |
23 | // Use a header bar when running in GNOME as this is the common style used
24 | // by applications and is the setup most users will be using (e.g. Ubuntu
25 | // desktop).
26 | // If running on X and not using GNOME then just use a traditional title bar
27 | // in case the window manager does more exotic layout, e.g. tiling.
28 | // If running on Wayland assume the header bar will work (may need changing
29 | // if future cases occur).
30 | gboolean use_header_bar = TRUE;
31 | #ifdef GDK_WINDOWING_X11
32 | GdkScreen *screen = gtk_window_get_screen(window);
33 | if (GDK_IS_X11_SCREEN(screen)) {
34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen);
35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) {
36 | use_header_bar = FALSE;
37 | }
38 | }
39 | #endif
40 | if (use_header_bar) {
41 | GtkHeaderBar *header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
42 | gtk_widget_show(GTK_WIDGET(header_bar));
43 | gtk_header_bar_set_title(header_bar, "screen_text_extractor_example");
44 | gtk_header_bar_set_show_close_button(header_bar, TRUE);
45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
46 | }
47 | else {
48 | gtk_window_set_title(window, "screen_text_extractor_example");
49 | }
50 |
51 | gtk_window_set_default_size(window, 1280, 720);
52 | gtk_widget_show(GTK_WIDGET(window));
53 |
54 | g_autoptr(FlDartProject) project = fl_dart_project_new();
55 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
56 |
57 | FlView* view = fl_view_new(project);
58 | gtk_widget_show(GTK_WIDGET(view));
59 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));
60 |
61 | fl_register_plugins(FL_PLUGIN_REGISTRY(view));
62 |
63 | gtk_widget_grab_focus(GTK_WIDGET(view));
64 | }
65 |
66 | // Implements GApplication::local_command_line.
67 | static gboolean my_application_local_command_line(GApplication* application, gchar ***arguments, int *exit_status) {
68 | MyApplication* self = MY_APPLICATION(application);
69 | // Strip out the first argument as it is the binary name.
70 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1);
71 |
72 | g_autoptr(GError) error = nullptr;
73 | if (!g_application_register(application, nullptr, &error)) {
74 | g_warning("Failed to register: %s", error->message);
75 | *exit_status = 1;
76 | return TRUE;
77 | }
78 |
79 | g_application_activate(application);
80 | *exit_status = 0;
81 |
82 | return TRUE;
83 | }
84 |
85 | // Implements GObject::dispose.
86 | static void my_application_dispose(GObject *object) {
87 | MyApplication* self = MY_APPLICATION(object);
88 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev);
89 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object);
90 | }
91 |
92 | static void my_application_class_init(MyApplicationClass* klass) {
93 | G_APPLICATION_CLASS(klass)->activate = my_application_activate;
94 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line;
95 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose;
96 | }
97 |
98 | static void my_application_init(MyApplication* self) {}
99 |
100 | MyApplication* my_application_new() {
101 | return MY_APPLICATION(g_object_new(my_application_get_type(),
102 | "application-id", APPLICATION_ID,
103 | "flags", G_APPLICATION_NON_UNIQUE,
104 | nullptr));
105 | }
106 |
--------------------------------------------------------------------------------
/example/linux/my_application.h:
--------------------------------------------------------------------------------
1 | #ifndef FLUTTER_MY_APPLICATION_H_
2 | #define FLUTTER_MY_APPLICATION_H_
3 |
4 | #include
5 |
6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION,
7 | GtkApplication)
8 |
9 | /**
10 | * my_application_new:
11 | *
12 | * Creates a new Flutter-based application.
13 | *
14 | * Returns: a new #MyApplication.
15 | */
16 | MyApplication* my_application_new();
17 |
18 | #endif // FLUTTER_MY_APPLICATION_H_
19 |
--------------------------------------------------------------------------------
/example/macos/.gitignore:
--------------------------------------------------------------------------------
1 | # Flutter-related
2 | **/Flutter/ephemeral/
3 | **/Pods/
4 |
5 | # Xcode-related
6 | **/xcuserdata/
7 |
--------------------------------------------------------------------------------
/example/macos/Flutter/Flutter-Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
2 | #include "ephemeral/Flutter-Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/example/macos/Flutter/Flutter-Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
2 | #include "ephemeral/Flutter-Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/example/macos/Flutter/GeneratedPluginRegistrant.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | import FlutterMacOS
6 | import Foundation
7 |
8 | import clipboard_watcher
9 | import hotkey_manager
10 | import screen_text_extractor
11 |
12 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
13 | ClipboardWatcherPlugin.register(with: registry.registrar(forPlugin: "ClipboardWatcherPlugin"))
14 | HotkeyManagerPlugin.register(with: registry.registrar(forPlugin: "HotkeyManagerPlugin"))
15 | ScreenTextExtractorPlugin.register(with: registry.registrar(forPlugin: "ScreenTextExtractorPlugin"))
16 | }
17 |
--------------------------------------------------------------------------------
/example/macos/Podfile:
--------------------------------------------------------------------------------
1 | platform :osx, '10.14'
2 |
3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true'
5 |
6 | project 'Runner', {
7 | 'Debug' => :debug,
8 | 'Profile' => :release,
9 | 'Release' => :release,
10 | }
11 |
12 | def flutter_root
13 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__)
14 | unless File.exist?(generated_xcode_build_settings_path)
15 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first"
16 | end
17 |
18 | File.foreach(generated_xcode_build_settings_path) do |line|
19 | matches = line.match(/FLUTTER_ROOT\=(.*)/)
20 | return matches[1].strip if matches
21 | end
22 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\""
23 | end
24 |
25 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
26 |
27 | flutter_macos_podfile_setup
28 |
29 | target 'Runner' do
30 | use_frameworks!
31 | use_modular_headers!
32 |
33 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
34 | end
35 |
36 | post_install do |installer|
37 | installer.pods_project.targets.each do |target|
38 | flutter_additional_macos_build_settings(target)
39 | end
40 | end
41 |
--------------------------------------------------------------------------------
/example/macos/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - clipboard_watcher (0.0.1):
3 | - FlutterMacOS
4 | - FlutterMacOS (1.0.0)
5 | - HotKey (0.1.2)
6 | - hotkey_manager (0.0.1):
7 | - FlutterMacOS
8 | - HotKey
9 | - screen_text_extractor (0.1.0):
10 | - FlutterMacOS
11 |
12 | DEPENDENCIES:
13 | - clipboard_watcher (from `Flutter/ephemeral/.symlinks/plugins/clipboard_watcher/macos`)
14 | - FlutterMacOS (from `Flutter/ephemeral`)
15 | - hotkey_manager (from `Flutter/ephemeral/.symlinks/plugins/hotkey_manager/macos`)
16 | - screen_text_extractor (from `Flutter/ephemeral/.symlinks/plugins/screen_text_extractor/macos`)
17 |
18 | SPEC REPOS:
19 | trunk:
20 | - HotKey
21 |
22 | EXTERNAL SOURCES:
23 | clipboard_watcher:
24 | :path: Flutter/ephemeral/.symlinks/plugins/clipboard_watcher/macos
25 | FlutterMacOS:
26 | :path: Flutter/ephemeral
27 | hotkey_manager:
28 | :path: Flutter/ephemeral/.symlinks/plugins/hotkey_manager/macos
29 | screen_text_extractor:
30 | :path: Flutter/ephemeral/.symlinks/plugins/screen_text_extractor/macos
31 |
32 | SPEC CHECKSUMS:
33 | clipboard_watcher: a71da520051c24c1b969a411b3e152d4dcc93ca5
34 | FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
35 | HotKey: ad59450195936c10992438c4210f673de5aee43e
36 | hotkey_manager: ad673457691f4d39e481be04a61da2ae07d81c62
37 | screen_text_extractor: 2c310f54af1dee881522e2b76bec9a668ebfe0cf
38 |
39 | PODFILE CHECKSUM: 353c8bcc5d5b0994e508d035b5431cfe18c1dea7
40 |
41 | COCOAPODS: 1.11.3
42 |
--------------------------------------------------------------------------------
/example/macos/Runner.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 54;
7 | objects = {
8 |
9 | /* Begin PBXAggregateTarget section */
10 | 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = {
11 | isa = PBXAggregateTarget;
12 | buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */;
13 | buildPhases = (
14 | 33CC111E2044C6BF0003C045 /* ShellScript */,
15 | );
16 | dependencies = (
17 | );
18 | name = "Flutter Assemble";
19 | productName = FLX;
20 | };
21 | /* End PBXAggregateTarget section */
22 |
23 | /* Begin PBXBuildFile section */
24 | 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; };
25 | 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; };
26 | 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; };
27 | 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; };
28 | 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; };
29 | C269D9FEB4654CA75FAFE148 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DF4B6954D235E9B7589F3B18 /* Pods_Runner.framework */; };
30 | /* End PBXBuildFile section */
31 |
32 | /* Begin PBXContainerItemProxy section */
33 | 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = {
34 | isa = PBXContainerItemProxy;
35 | containerPortal = 33CC10E52044A3C60003C045 /* Project object */;
36 | proxyType = 1;
37 | remoteGlobalIDString = 33CC111A2044C6BA0003C045;
38 | remoteInfo = FLX;
39 | };
40 | /* End PBXContainerItemProxy section */
41 |
42 | /* Begin PBXCopyFilesBuildPhase section */
43 | 33CC110E2044A8840003C045 /* Bundle Framework */ = {
44 | isa = PBXCopyFilesBuildPhase;
45 | buildActionMask = 2147483647;
46 | dstPath = "";
47 | dstSubfolderSpec = 10;
48 | files = (
49 | );
50 | name = "Bundle Framework";
51 | runOnlyForDeploymentPostprocessing = 0;
52 | };
53 | /* End PBXCopyFilesBuildPhase section */
54 |
55 | /* Begin PBXFileReference section */
56 | 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; };
57 | 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; };
58 | 33CC10ED2044A3C60003C045 /* screen_text_extractor_example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = screen_text_extractor_example.app; sourceTree = BUILT_PRODUCTS_DIR; };
59 | 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
60 | 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; };
61 | 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; };
62 | 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; };
63 | 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; };
64 | 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; };
65 | 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; };
66 | 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; };
67 | 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; };
68 | 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; };
69 | 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; };
70 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; };
71 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; };
72 | AE30FBE7D5094F4E31A7E701 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; };
73 | BFE6A5EA7C41A9980BB8908F /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; };
74 | DF4B6954D235E9B7589F3B18 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
75 | F0500317ADE76FD1B831F200 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; };
76 | /* End PBXFileReference section */
77 |
78 | /* Begin PBXFrameworksBuildPhase section */
79 | 33CC10EA2044A3C60003C045 /* Frameworks */ = {
80 | isa = PBXFrameworksBuildPhase;
81 | buildActionMask = 2147483647;
82 | files = (
83 | C269D9FEB4654CA75FAFE148 /* Pods_Runner.framework in Frameworks */,
84 | );
85 | runOnlyForDeploymentPostprocessing = 0;
86 | };
87 | /* End PBXFrameworksBuildPhase section */
88 |
89 | /* Begin PBXGroup section */
90 | 33BA886A226E78AF003329D5 /* Configs */ = {
91 | isa = PBXGroup;
92 | children = (
93 | 33E5194F232828860026EE4D /* AppInfo.xcconfig */,
94 | 9740EEB21CF90195004384FC /* Debug.xcconfig */,
95 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
96 | 333000ED22D3DE5D00554162 /* Warnings.xcconfig */,
97 | );
98 | path = Configs;
99 | sourceTree = "";
100 | };
101 | 33CC10E42044A3C60003C045 = {
102 | isa = PBXGroup;
103 | children = (
104 | 33FAB671232836740065AC1E /* Runner */,
105 | 33CEB47122A05771004F2AC0 /* Flutter */,
106 | 33CC10EE2044A3C60003C045 /* Products */,
107 | D73912EC22F37F3D000D13A0 /* Frameworks */,
108 | F412D6C38C97EC8AD0FB5FD5 /* Pods */,
109 | );
110 | sourceTree = "";
111 | };
112 | 33CC10EE2044A3C60003C045 /* Products */ = {
113 | isa = PBXGroup;
114 | children = (
115 | 33CC10ED2044A3C60003C045 /* screen_text_extractor_example.app */,
116 | );
117 | name = Products;
118 | sourceTree = "";
119 | };
120 | 33CC11242044D66E0003C045 /* Resources */ = {
121 | isa = PBXGroup;
122 | children = (
123 | 33CC10F22044A3C60003C045 /* Assets.xcassets */,
124 | 33CC10F42044A3C60003C045 /* MainMenu.xib */,
125 | 33CC10F72044A3C60003C045 /* Info.plist */,
126 | );
127 | name = Resources;
128 | path = ..;
129 | sourceTree = "";
130 | };
131 | 33CEB47122A05771004F2AC0 /* Flutter */ = {
132 | isa = PBXGroup;
133 | children = (
134 | 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */,
135 | 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */,
136 | 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */,
137 | 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */,
138 | );
139 | path = Flutter;
140 | sourceTree = "";
141 | };
142 | 33FAB671232836740065AC1E /* Runner */ = {
143 | isa = PBXGroup;
144 | children = (
145 | 33CC10F02044A3C60003C045 /* AppDelegate.swift */,
146 | 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */,
147 | 33E51913231747F40026EE4D /* DebugProfile.entitlements */,
148 | 33E51914231749380026EE4D /* Release.entitlements */,
149 | 33CC11242044D66E0003C045 /* Resources */,
150 | 33BA886A226E78AF003329D5 /* Configs */,
151 | );
152 | path = Runner;
153 | sourceTree = "";
154 | };
155 | D73912EC22F37F3D000D13A0 /* Frameworks */ = {
156 | isa = PBXGroup;
157 | children = (
158 | DF4B6954D235E9B7589F3B18 /* Pods_Runner.framework */,
159 | );
160 | name = Frameworks;
161 | sourceTree = "";
162 | };
163 | F412D6C38C97EC8AD0FB5FD5 /* Pods */ = {
164 | isa = PBXGroup;
165 | children = (
166 | F0500317ADE76FD1B831F200 /* Pods-Runner.debug.xcconfig */,
167 | BFE6A5EA7C41A9980BB8908F /* Pods-Runner.release.xcconfig */,
168 | AE30FBE7D5094F4E31A7E701 /* Pods-Runner.profile.xcconfig */,
169 | );
170 | path = Pods;
171 | sourceTree = "";
172 | };
173 | /* End PBXGroup section */
174 |
175 | /* Begin PBXNativeTarget section */
176 | 33CC10EC2044A3C60003C045 /* Runner */ = {
177 | isa = PBXNativeTarget;
178 | buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */;
179 | buildPhases = (
180 | 6A174767A174AF6D365210A4 /* [CP] Check Pods Manifest.lock */,
181 | 33CC10E92044A3C60003C045 /* Sources */,
182 | 33CC10EA2044A3C60003C045 /* Frameworks */,
183 | 33CC10EB2044A3C60003C045 /* Resources */,
184 | 33CC110E2044A8840003C045 /* Bundle Framework */,
185 | 3399D490228B24CF009A79C7 /* ShellScript */,
186 | 63036430BBAA585AD8C335BF /* [CP] Embed Pods Frameworks */,
187 | );
188 | buildRules = (
189 | );
190 | dependencies = (
191 | 33CC11202044C79F0003C045 /* PBXTargetDependency */,
192 | );
193 | name = Runner;
194 | productName = Runner;
195 | productReference = 33CC10ED2044A3C60003C045 /* screen_text_extractor_example.app */;
196 | productType = "com.apple.product-type.application";
197 | };
198 | /* End PBXNativeTarget section */
199 |
200 | /* Begin PBXProject section */
201 | 33CC10E52044A3C60003C045 /* Project object */ = {
202 | isa = PBXProject;
203 | attributes = {
204 | LastSwiftUpdateCheck = 0920;
205 | LastUpgradeCheck = 1300;
206 | ORGANIZATIONNAME = "";
207 | TargetAttributes = {
208 | 33CC10EC2044A3C60003C045 = {
209 | CreatedOnToolsVersion = 9.2;
210 | LastSwiftMigration = 1100;
211 | ProvisioningStyle = Automatic;
212 | SystemCapabilities = {
213 | com.apple.Sandbox = {
214 | enabled = 1;
215 | };
216 | };
217 | };
218 | 33CC111A2044C6BA0003C045 = {
219 | CreatedOnToolsVersion = 9.2;
220 | ProvisioningStyle = Manual;
221 | };
222 | };
223 | };
224 | buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */;
225 | compatibilityVersion = "Xcode 9.3";
226 | developmentRegion = en;
227 | hasScannedForEncodings = 0;
228 | knownRegions = (
229 | en,
230 | Base,
231 | );
232 | mainGroup = 33CC10E42044A3C60003C045;
233 | productRefGroup = 33CC10EE2044A3C60003C045 /* Products */;
234 | projectDirPath = "";
235 | projectRoot = "";
236 | targets = (
237 | 33CC10EC2044A3C60003C045 /* Runner */,
238 | 33CC111A2044C6BA0003C045 /* Flutter Assemble */,
239 | );
240 | };
241 | /* End PBXProject section */
242 |
243 | /* Begin PBXResourcesBuildPhase section */
244 | 33CC10EB2044A3C60003C045 /* Resources */ = {
245 | isa = PBXResourcesBuildPhase;
246 | buildActionMask = 2147483647;
247 | files = (
248 | 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */,
249 | 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */,
250 | );
251 | runOnlyForDeploymentPostprocessing = 0;
252 | };
253 | /* End PBXResourcesBuildPhase section */
254 |
255 | /* Begin PBXShellScriptBuildPhase section */
256 | 3399D490228B24CF009A79C7 /* ShellScript */ = {
257 | isa = PBXShellScriptBuildPhase;
258 | alwaysOutOfDate = 1;
259 | buildActionMask = 2147483647;
260 | files = (
261 | );
262 | inputFileListPaths = (
263 | );
264 | inputPaths = (
265 | );
266 | outputFileListPaths = (
267 | );
268 | outputPaths = (
269 | );
270 | runOnlyForDeploymentPostprocessing = 0;
271 | shellPath = /bin/sh;
272 | shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n";
273 | };
274 | 33CC111E2044C6BF0003C045 /* ShellScript */ = {
275 | isa = PBXShellScriptBuildPhase;
276 | buildActionMask = 2147483647;
277 | files = (
278 | );
279 | inputFileListPaths = (
280 | Flutter/ephemeral/FlutterInputs.xcfilelist,
281 | );
282 | inputPaths = (
283 | Flutter/ephemeral/tripwire,
284 | );
285 | outputFileListPaths = (
286 | Flutter/ephemeral/FlutterOutputs.xcfilelist,
287 | );
288 | outputPaths = (
289 | );
290 | runOnlyForDeploymentPostprocessing = 0;
291 | shellPath = /bin/sh;
292 | shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire";
293 | };
294 | 63036430BBAA585AD8C335BF /* [CP] Embed Pods Frameworks */ = {
295 | isa = PBXShellScriptBuildPhase;
296 | buildActionMask = 2147483647;
297 | files = (
298 | );
299 | inputFileListPaths = (
300 | "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
301 | );
302 | name = "[CP] Embed Pods Frameworks";
303 | outputFileListPaths = (
304 | "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
305 | );
306 | runOnlyForDeploymentPostprocessing = 0;
307 | shellPath = /bin/sh;
308 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
309 | showEnvVarsInLog = 0;
310 | };
311 | 6A174767A174AF6D365210A4 /* [CP] Check Pods Manifest.lock */ = {
312 | isa = PBXShellScriptBuildPhase;
313 | buildActionMask = 2147483647;
314 | files = (
315 | );
316 | inputFileListPaths = (
317 | );
318 | inputPaths = (
319 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
320 | "${PODS_ROOT}/Manifest.lock",
321 | );
322 | name = "[CP] Check Pods Manifest.lock";
323 | outputFileListPaths = (
324 | );
325 | outputPaths = (
326 | "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
327 | );
328 | runOnlyForDeploymentPostprocessing = 0;
329 | shellPath = /bin/sh;
330 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
331 | showEnvVarsInLog = 0;
332 | };
333 | /* End PBXShellScriptBuildPhase section */
334 |
335 | /* Begin PBXSourcesBuildPhase section */
336 | 33CC10E92044A3C60003C045 /* Sources */ = {
337 | isa = PBXSourcesBuildPhase;
338 | buildActionMask = 2147483647;
339 | files = (
340 | 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */,
341 | 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */,
342 | 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */,
343 | );
344 | runOnlyForDeploymentPostprocessing = 0;
345 | };
346 | /* End PBXSourcesBuildPhase section */
347 |
348 | /* Begin PBXTargetDependency section */
349 | 33CC11202044C79F0003C045 /* PBXTargetDependency */ = {
350 | isa = PBXTargetDependency;
351 | target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */;
352 | targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */;
353 | };
354 | /* End PBXTargetDependency section */
355 |
356 | /* Begin PBXVariantGroup section */
357 | 33CC10F42044A3C60003C045 /* MainMenu.xib */ = {
358 | isa = PBXVariantGroup;
359 | children = (
360 | 33CC10F52044A3C60003C045 /* Base */,
361 | );
362 | name = MainMenu.xib;
363 | path = Runner;
364 | sourceTree = "";
365 | };
366 | /* End PBXVariantGroup section */
367 |
368 | /* Begin XCBuildConfiguration section */
369 | 338D0CE9231458BD00FA5F75 /* Profile */ = {
370 | isa = XCBuildConfiguration;
371 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
372 | buildSettings = {
373 | ALWAYS_SEARCH_USER_PATHS = NO;
374 | CLANG_ANALYZER_NONNULL = YES;
375 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
376 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
377 | CLANG_CXX_LIBRARY = "libc++";
378 | CLANG_ENABLE_MODULES = YES;
379 | CLANG_ENABLE_OBJC_ARC = YES;
380 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
381 | CLANG_WARN_BOOL_CONVERSION = YES;
382 | CLANG_WARN_CONSTANT_CONVERSION = YES;
383 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
384 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
385 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
386 | CLANG_WARN_EMPTY_BODY = YES;
387 | CLANG_WARN_ENUM_CONVERSION = YES;
388 | CLANG_WARN_INFINITE_RECURSION = YES;
389 | CLANG_WARN_INT_CONVERSION = YES;
390 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
391 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
392 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
393 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
394 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
395 | CODE_SIGN_IDENTITY = "-";
396 | COPY_PHASE_STRIP = NO;
397 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
398 | ENABLE_NS_ASSERTIONS = NO;
399 | ENABLE_STRICT_OBJC_MSGSEND = YES;
400 | GCC_C_LANGUAGE_STANDARD = gnu11;
401 | GCC_NO_COMMON_BLOCKS = YES;
402 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
403 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
404 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
405 | GCC_WARN_UNUSED_FUNCTION = YES;
406 | GCC_WARN_UNUSED_VARIABLE = YES;
407 | MACOSX_DEPLOYMENT_TARGET = 10.14;
408 | MTL_ENABLE_DEBUG_INFO = NO;
409 | SDKROOT = macosx;
410 | SWIFT_COMPILATION_MODE = wholemodule;
411 | SWIFT_OPTIMIZATION_LEVEL = "-O";
412 | };
413 | name = Profile;
414 | };
415 | 338D0CEA231458BD00FA5F75 /* Profile */ = {
416 | isa = XCBuildConfiguration;
417 | baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */;
418 | buildSettings = {
419 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
420 | CLANG_ENABLE_MODULES = YES;
421 | CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
422 | CODE_SIGN_STYLE = Automatic;
423 | COMBINE_HIDPI_IMAGES = YES;
424 | INFOPLIST_FILE = Runner/Info.plist;
425 | LD_RUNPATH_SEARCH_PATHS = (
426 | "$(inherited)",
427 | "@executable_path/../Frameworks",
428 | );
429 | PROVISIONING_PROFILE_SPECIFIER = "";
430 | SWIFT_VERSION = 5.0;
431 | };
432 | name = Profile;
433 | };
434 | 338D0CEB231458BD00FA5F75 /* Profile */ = {
435 | isa = XCBuildConfiguration;
436 | buildSettings = {
437 | CODE_SIGN_STYLE = Manual;
438 | PRODUCT_NAME = "$(TARGET_NAME)";
439 | };
440 | name = Profile;
441 | };
442 | 33CC10F92044A3C60003C045 /* Debug */ = {
443 | isa = XCBuildConfiguration;
444 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
445 | buildSettings = {
446 | ALWAYS_SEARCH_USER_PATHS = NO;
447 | CLANG_ANALYZER_NONNULL = YES;
448 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
449 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
450 | CLANG_CXX_LIBRARY = "libc++";
451 | CLANG_ENABLE_MODULES = YES;
452 | CLANG_ENABLE_OBJC_ARC = YES;
453 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
454 | CLANG_WARN_BOOL_CONVERSION = YES;
455 | CLANG_WARN_CONSTANT_CONVERSION = YES;
456 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
457 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
458 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
459 | CLANG_WARN_EMPTY_BODY = YES;
460 | CLANG_WARN_ENUM_CONVERSION = YES;
461 | CLANG_WARN_INFINITE_RECURSION = YES;
462 | CLANG_WARN_INT_CONVERSION = YES;
463 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
464 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
465 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
466 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
467 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
468 | CODE_SIGN_IDENTITY = "-";
469 | COPY_PHASE_STRIP = NO;
470 | DEBUG_INFORMATION_FORMAT = dwarf;
471 | ENABLE_STRICT_OBJC_MSGSEND = YES;
472 | ENABLE_TESTABILITY = YES;
473 | GCC_C_LANGUAGE_STANDARD = gnu11;
474 | GCC_DYNAMIC_NO_PIC = NO;
475 | GCC_NO_COMMON_BLOCKS = YES;
476 | GCC_OPTIMIZATION_LEVEL = 0;
477 | GCC_PREPROCESSOR_DEFINITIONS = (
478 | "DEBUG=1",
479 | "$(inherited)",
480 | );
481 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
482 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
483 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
484 | GCC_WARN_UNUSED_FUNCTION = YES;
485 | GCC_WARN_UNUSED_VARIABLE = YES;
486 | MACOSX_DEPLOYMENT_TARGET = 10.14;
487 | MTL_ENABLE_DEBUG_INFO = YES;
488 | ONLY_ACTIVE_ARCH = YES;
489 | SDKROOT = macosx;
490 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
491 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
492 | };
493 | name = Debug;
494 | };
495 | 33CC10FA2044A3C60003C045 /* Release */ = {
496 | isa = XCBuildConfiguration;
497 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
498 | buildSettings = {
499 | ALWAYS_SEARCH_USER_PATHS = NO;
500 | CLANG_ANALYZER_NONNULL = YES;
501 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
502 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
503 | CLANG_CXX_LIBRARY = "libc++";
504 | CLANG_ENABLE_MODULES = YES;
505 | CLANG_ENABLE_OBJC_ARC = YES;
506 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
507 | CLANG_WARN_BOOL_CONVERSION = YES;
508 | CLANG_WARN_CONSTANT_CONVERSION = YES;
509 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
510 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
511 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
512 | CLANG_WARN_EMPTY_BODY = YES;
513 | CLANG_WARN_ENUM_CONVERSION = YES;
514 | CLANG_WARN_INFINITE_RECURSION = YES;
515 | CLANG_WARN_INT_CONVERSION = YES;
516 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
517 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
518 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
519 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
520 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
521 | CODE_SIGN_IDENTITY = "-";
522 | COPY_PHASE_STRIP = NO;
523 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
524 | ENABLE_NS_ASSERTIONS = NO;
525 | ENABLE_STRICT_OBJC_MSGSEND = YES;
526 | GCC_C_LANGUAGE_STANDARD = gnu11;
527 | GCC_NO_COMMON_BLOCKS = YES;
528 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
529 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
530 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
531 | GCC_WARN_UNUSED_FUNCTION = YES;
532 | GCC_WARN_UNUSED_VARIABLE = YES;
533 | MACOSX_DEPLOYMENT_TARGET = 10.14;
534 | MTL_ENABLE_DEBUG_INFO = NO;
535 | SDKROOT = macosx;
536 | SWIFT_COMPILATION_MODE = wholemodule;
537 | SWIFT_OPTIMIZATION_LEVEL = "-O";
538 | };
539 | name = Release;
540 | };
541 | 33CC10FC2044A3C60003C045 /* Debug */ = {
542 | isa = XCBuildConfiguration;
543 | baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */;
544 | buildSettings = {
545 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
546 | CLANG_ENABLE_MODULES = YES;
547 | CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
548 | CODE_SIGN_STYLE = Automatic;
549 | COMBINE_HIDPI_IMAGES = YES;
550 | INFOPLIST_FILE = Runner/Info.plist;
551 | LD_RUNPATH_SEARCH_PATHS = (
552 | "$(inherited)",
553 | "@executable_path/../Frameworks",
554 | );
555 | PROVISIONING_PROFILE_SPECIFIER = "";
556 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
557 | SWIFT_VERSION = 5.0;
558 | };
559 | name = Debug;
560 | };
561 | 33CC10FD2044A3C60003C045 /* Release */ = {
562 | isa = XCBuildConfiguration;
563 | baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */;
564 | buildSettings = {
565 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
566 | CLANG_ENABLE_MODULES = YES;
567 | CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements;
568 | CODE_SIGN_STYLE = Automatic;
569 | COMBINE_HIDPI_IMAGES = YES;
570 | INFOPLIST_FILE = Runner/Info.plist;
571 | LD_RUNPATH_SEARCH_PATHS = (
572 | "$(inherited)",
573 | "@executable_path/../Frameworks",
574 | );
575 | PROVISIONING_PROFILE_SPECIFIER = "";
576 | SWIFT_VERSION = 5.0;
577 | };
578 | name = Release;
579 | };
580 | 33CC111C2044C6BA0003C045 /* Debug */ = {
581 | isa = XCBuildConfiguration;
582 | buildSettings = {
583 | CODE_SIGN_STYLE = Manual;
584 | PRODUCT_NAME = "$(TARGET_NAME)";
585 | };
586 | name = Debug;
587 | };
588 | 33CC111D2044C6BA0003C045 /* Release */ = {
589 | isa = XCBuildConfiguration;
590 | buildSettings = {
591 | CODE_SIGN_STYLE = Automatic;
592 | PRODUCT_NAME = "$(TARGET_NAME)";
593 | };
594 | name = Release;
595 | };
596 | /* End XCBuildConfiguration section */
597 |
598 | /* Begin XCConfigurationList section */
599 | 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = {
600 | isa = XCConfigurationList;
601 | buildConfigurations = (
602 | 33CC10F92044A3C60003C045 /* Debug */,
603 | 33CC10FA2044A3C60003C045 /* Release */,
604 | 338D0CE9231458BD00FA5F75 /* Profile */,
605 | );
606 | defaultConfigurationIsVisible = 0;
607 | defaultConfigurationName = Release;
608 | };
609 | 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = {
610 | isa = XCConfigurationList;
611 | buildConfigurations = (
612 | 33CC10FC2044A3C60003C045 /* Debug */,
613 | 33CC10FD2044A3C60003C045 /* Release */,
614 | 338D0CEA231458BD00FA5F75 /* Profile */,
615 | );
616 | defaultConfigurationIsVisible = 0;
617 | defaultConfigurationName = Release;
618 | };
619 | 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = {
620 | isa = XCConfigurationList;
621 | buildConfigurations = (
622 | 33CC111C2044C6BA0003C045 /* Debug */,
623 | 33CC111D2044C6BA0003C045 /* Release */,
624 | 338D0CEB231458BD00FA5F75 /* Profile */,
625 | );
626 | defaultConfigurationIsVisible = 0;
627 | defaultConfigurationName = Release;
628 | };
629 | /* End XCConfigurationList section */
630 | };
631 | rootObject = 33CC10E52044A3C60003C045 /* Project object */;
632 | }
633 |
--------------------------------------------------------------------------------
/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
37 |
38 |
39 |
40 |
41 |
42 |
52 |
54 |
60 |
61 |
62 |
63 |
64 |
65 |
71 |
73 |
79 |
80 |
81 |
82 |
84 |
85 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/example/macos/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/macos/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 | import FlutterMacOS
3 |
4 | @NSApplicationMain
5 | class AppDelegate: FlutterAppDelegate {
6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
7 | return true
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "16x16",
5 | "idiom" : "mac",
6 | "filename" : "app_icon_16.png",
7 | "scale" : "1x"
8 | },
9 | {
10 | "size" : "16x16",
11 | "idiom" : "mac",
12 | "filename" : "app_icon_32.png",
13 | "scale" : "2x"
14 | },
15 | {
16 | "size" : "32x32",
17 | "idiom" : "mac",
18 | "filename" : "app_icon_32.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "32x32",
23 | "idiom" : "mac",
24 | "filename" : "app_icon_64.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "128x128",
29 | "idiom" : "mac",
30 | "filename" : "app_icon_128.png",
31 | "scale" : "1x"
32 | },
33 | {
34 | "size" : "128x128",
35 | "idiom" : "mac",
36 | "filename" : "app_icon_256.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "256x256",
41 | "idiom" : "mac",
42 | "filename" : "app_icon_256.png",
43 | "scale" : "1x"
44 | },
45 | {
46 | "size" : "256x256",
47 | "idiom" : "mac",
48 | "filename" : "app_icon_512.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "512x512",
53 | "idiom" : "mac",
54 | "filename" : "app_icon_512.png",
55 | "scale" : "1x"
56 | },
57 | {
58 | "size" : "512x512",
59 | "idiom" : "mac",
60 | "filename" : "app_icon_1024.png",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leanflutter/screen_text_extractor/787279f829d0d521eb3690f6d4c03fe83ec1cbb7/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leanflutter/screen_text_extractor/787279f829d0d521eb3690f6d4c03fe83ec1cbb7/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leanflutter/screen_text_extractor/787279f829d0d521eb3690f6d4c03fe83ec1cbb7/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leanflutter/screen_text_extractor/787279f829d0d521eb3690f6d4c03fe83ec1cbb7/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leanflutter/screen_text_extractor/787279f829d0d521eb3690f6d4c03fe83ec1cbb7/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leanflutter/screen_text_extractor/787279f829d0d521eb3690f6d4c03fe83ec1cbb7/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png
--------------------------------------------------------------------------------
/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leanflutter/screen_text_extractor/787279f829d0d521eb3690f6d4c03fe83ec1cbb7/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png
--------------------------------------------------------------------------------
/example/macos/Runner/Base.lproj/MainMenu.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
--------------------------------------------------------------------------------
/example/macos/Runner/Configs/AppInfo.xcconfig:
--------------------------------------------------------------------------------
1 | // Application-level settings for the Runner target.
2 | //
3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the
4 | // future. If not, the values below would default to using the project name when this becomes a
5 | // 'flutter create' template.
6 |
7 | // The application's name. By default this is also the title of the Flutter window.
8 | PRODUCT_NAME = screen_text_extractor_example
9 |
10 | // The application's bundle identifier
11 | PRODUCT_BUNDLE_IDENTIFIER = org.leanflutter.plugins.screenTextExtractorExample
12 |
13 | // The copyright displayed in application information
14 | PRODUCT_COPYRIGHT = Copyright © 2021 org.leanflutter.plugins. All rights reserved.
15 |
--------------------------------------------------------------------------------
/example/macos/Runner/Configs/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "../../Flutter/Flutter-Debug.xcconfig"
2 | #include "Warnings.xcconfig"
3 |
--------------------------------------------------------------------------------
/example/macos/Runner/Configs/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "../../Flutter/Flutter-Release.xcconfig"
2 | #include "Warnings.xcconfig"
3 |
--------------------------------------------------------------------------------
/example/macos/Runner/Configs/Warnings.xcconfig:
--------------------------------------------------------------------------------
1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings
2 | GCC_WARN_UNDECLARED_SELECTOR = YES
3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES
4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE
5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES
6 | CLANG_WARN_PRAGMA_PACK = YES
7 | CLANG_WARN_STRICT_PROTOTYPES = YES
8 | CLANG_WARN_COMMA = YES
9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES
10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES
11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
12 | GCC_WARN_SHADOW = YES
13 | CLANG_WARN_UNREACHABLE_CODE = YES
14 |
--------------------------------------------------------------------------------
/example/macos/Runner/DebugProfile.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.app-sandbox
6 |
7 | com.apple.security.cs.allow-jit
8 |
9 | com.apple.security.network.server
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/example/macos/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | $(FLUTTER_BUILD_NAME)
21 | CFBundleVersion
22 | $(FLUTTER_BUILD_NUMBER)
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | $(PRODUCT_COPYRIGHT)
27 | NSMainNibFile
28 | MainMenu
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/example/macos/Runner/MainFlutterWindow.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 | import FlutterMacOS
3 |
4 | class MainFlutterWindow: NSWindow {
5 | override func awakeFromNib() {
6 | let flutterViewController = FlutterViewController.init()
7 | let windowFrame = self.frame
8 | self.contentViewController = flutterViewController
9 | self.setFrame(windowFrame, display: true)
10 |
11 | RegisterGeneratedPlugins(registry: flutterViewController)
12 |
13 | super.awakeFromNib()
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/example/macos/Runner/Release.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.app-sandbox
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/pubspec.lock:
--------------------------------------------------------------------------------
1 | # Generated by pub
2 | # See https://dart.dev/tools/pub/glossary#lockfile
3 | packages:
4 | async:
5 | dependency: transitive
6 | description:
7 | name: async
8 | sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
9 | url: "https://pub.dev"
10 | source: hosted
11 | version: "2.11.0"
12 | boolean_selector:
13 | dependency: transitive
14 | description:
15 | name: boolean_selector
16 | sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
17 | url: "https://pub.dev"
18 | source: hosted
19 | version: "2.1.1"
20 | bot_toast:
21 | dependency: "direct main"
22 | description:
23 | name: bot_toast
24 | sha256: "1a432d6e4bad2282615403134708b232ef68ae99b0b3d8604fca85699a75b4b5"
25 | url: "https://pub.dev"
26 | source: hosted
27 | version: "4.0.1"
28 | characters:
29 | dependency: transitive
30 | description:
31 | name: characters
32 | sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
33 | url: "https://pub.dev"
34 | source: hosted
35 | version: "1.3.0"
36 | clipboard_watcher:
37 | dependency: transitive
38 | description:
39 | name: clipboard_watcher
40 | sha256: "2fa9c728f46962668dbc1c07870695c9163524f8dbea25dc176277d1ef1cc2bd"
41 | url: "https://pub.dev"
42 | source: hosted
43 | version: "0.2.0"
44 | clock:
45 | dependency: transitive
46 | description:
47 | name: clock
48 | sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
49 | url: "https://pub.dev"
50 | source: hosted
51 | version: "1.1.1"
52 | collection:
53 | dependency: transitive
54 | description:
55 | name: collection
56 | sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
57 | url: "https://pub.dev"
58 | source: hosted
59 | version: "1.17.1"
60 | crypto:
61 | dependency: transitive
62 | description:
63 | name: crypto
64 | sha256: cf75650c66c0316274e21d7c43d3dea246273af5955bd94e8184837cd577575c
65 | url: "https://pub.dev"
66 | source: hosted
67 | version: "3.0.1"
68 | cupertino_icons:
69 | dependency: "direct main"
70 | description:
71 | name: cupertino_icons
72 | sha256: "486b7bc707424572cdf7bd7e812a0c146de3fd47ecadf070254cc60383f21dd8"
73 | url: "https://pub.dev"
74 | source: hosted
75 | version: "1.0.3"
76 | fake_async:
77 | dependency: transitive
78 | description:
79 | name: fake_async
80 | sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
81 | url: "https://pub.dev"
82 | source: hosted
83 | version: "1.3.1"
84 | flutter:
85 | dependency: "direct main"
86 | description: flutter
87 | source: sdk
88 | version: "0.0.0"
89 | flutter_lints:
90 | dependency: "direct dev"
91 | description:
92 | name: flutter_lints
93 | sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c
94 | url: "https://pub.dev"
95 | source: hosted
96 | version: "2.0.1"
97 | flutter_test:
98 | dependency: "direct dev"
99 | description: flutter
100 | source: sdk
101 | version: "0.0.0"
102 | flutter_web_plugins:
103 | dependency: transitive
104 | description: flutter
105 | source: sdk
106 | version: "0.0.0"
107 | hotkey_manager:
108 | dependency: "direct main"
109 | description:
110 | name: hotkey_manager
111 | sha256: "1af91718fd05d60f554ab9819051b18206a336a99b7821f205ee171b3312dbc4"
112 | url: "https://pub.dev"
113 | source: hosted
114 | version: "0.1.0"
115 | js:
116 | dependency: transitive
117 | description:
118 | name: js
119 | sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
120 | url: "https://pub.dev"
121 | source: hosted
122 | version: "0.6.7"
123 | lints:
124 | dependency: transitive
125 | description:
126 | name: lints
127 | sha256: "5e4a9cd06d447758280a8ac2405101e0e2094d2a1dbdd3756aec3fe7775ba593"
128 | url: "https://pub.dev"
129 | source: hosted
130 | version: "2.0.1"
131 | matcher:
132 | dependency: transitive
133 | description:
134 | name: matcher
135 | sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
136 | url: "https://pub.dev"
137 | source: hosted
138 | version: "0.12.15"
139 | material_color_utilities:
140 | dependency: transitive
141 | description:
142 | name: material_color_utilities
143 | sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
144 | url: "https://pub.dev"
145 | source: hosted
146 | version: "0.2.0"
147 | meta:
148 | dependency: transitive
149 | description:
150 | name: meta
151 | sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
152 | url: "https://pub.dev"
153 | source: hosted
154 | version: "1.9.1"
155 | path:
156 | dependency: transitive
157 | description:
158 | name: path
159 | sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
160 | url: "https://pub.dev"
161 | source: hosted
162 | version: "1.8.3"
163 | preference_list:
164 | dependency: "direct main"
165 | description:
166 | name: preference_list
167 | sha256: d3419b2ec57a6ad2156bd682a46cf3194bf162b36bb013790c7b29e6438f107a
168 | url: "https://pub.dev"
169 | source: hosted
170 | version: "0.0.1"
171 | screen_text_extractor:
172 | dependency: "direct main"
173 | description:
174 | path: ".."
175 | relative: true
176 | source: path
177 | version: "0.1.3"
178 | sky_engine:
179 | dependency: transitive
180 | description: flutter
181 | source: sdk
182 | version: "0.0.99"
183 | source_span:
184 | dependency: transitive
185 | description:
186 | name: source_span
187 | sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
188 | url: "https://pub.dev"
189 | source: hosted
190 | version: "1.9.1"
191 | stack_trace:
192 | dependency: transitive
193 | description:
194 | name: stack_trace
195 | sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
196 | url: "https://pub.dev"
197 | source: hosted
198 | version: "1.11.0"
199 | stream_channel:
200 | dependency: transitive
201 | description:
202 | name: stream_channel
203 | sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
204 | url: "https://pub.dev"
205 | source: hosted
206 | version: "2.1.1"
207 | string_scanner:
208 | dependency: transitive
209 | description:
210 | name: string_scanner
211 | sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
212 | url: "https://pub.dev"
213 | source: hosted
214 | version: "1.2.0"
215 | term_glyph:
216 | dependency: transitive
217 | description:
218 | name: term_glyph
219 | sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
220 | url: "https://pub.dev"
221 | source: hosted
222 | version: "1.2.1"
223 | test_api:
224 | dependency: transitive
225 | description:
226 | name: test_api
227 | sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb
228 | url: "https://pub.dev"
229 | source: hosted
230 | version: "0.5.1"
231 | typed_data:
232 | dependency: transitive
233 | description:
234 | name: typed_data
235 | sha256: "53bdf7e979cfbf3e28987552fd72f637e63f3c8724c9e56d9246942dc2fa36ee"
236 | url: "https://pub.dev"
237 | source: hosted
238 | version: "1.3.0"
239 | uuid:
240 | dependency: transitive
241 | description:
242 | name: uuid
243 | sha256: "0ea20bfc625477e17f08a92d112272a071609b275ce4ca10ad853e1426ca3758"
244 | url: "https://pub.dev"
245 | source: hosted
246 | version: "3.0.4"
247 | vector_math:
248 | dependency: transitive
249 | description:
250 | name: vector_math
251 | sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
252 | url: "https://pub.dev"
253 | source: hosted
254 | version: "2.1.4"
255 | sdks:
256 | dart: ">=3.0.0-0 <4.0.0"
257 | flutter: ">=3.3.0"
258 |
--------------------------------------------------------------------------------
/example/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: screen_text_extractor_example
2 | description: Demonstrates how to use the screen_text_extractor plugin.
3 |
4 | # The following line prevents the package from being accidentally published to
5 | # pub.dev using `flutter pub publish`. This is preferred for private packages.
6 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev
7 |
8 | environment:
9 | sdk: ">=2.12.0 <3.0.0"
10 |
11 | # Dependencies specify other packages that your package needs in order to work.
12 | # To automatically upgrade your package dependencies to the latest versions
13 | # consider running `flutter pub upgrade --major-versions`. Alternatively,
14 | # dependencies can be manually updated by changing the version numbers below to
15 | # the latest version available on pub.dev. To see which dependencies have newer
16 | # versions available, run `flutter pub outdated`.
17 | dependencies:
18 | flutter:
19 | sdk: flutter
20 |
21 | screen_text_extractor:
22 | # When depending on this package from a real application you should use:
23 | # screen_text_extractor: ^x.y.z
24 | # See https://dart.dev/tools/pub/dependencies#version-constraints
25 | # The example app is bundled with the plugin so we use a path dependency on
26 | # the parent directory to use the current plugin's version.
27 | path: ../
28 |
29 | bot_toast: ^4.0.1
30 | hotkey_manager: ^0.1.0
31 | preference_list: ^0.0.1
32 |
33 | # The following adds the Cupertino Icons font to your application.
34 | # Use with the CupertinoIcons class for iOS style icons.
35 | cupertino_icons: ^1.0.2
36 |
37 |
38 | dev_dependencies:
39 | flutter_test:
40 | sdk: flutter
41 |
42 | # The "flutter_lints" package below contains a set of recommended lints to
43 | # encourage good coding practices. The lint set provided by the package is
44 | # activated in the `analysis_options.yaml` file located at the root of your
45 | # package. See that file for information about deactivating specific lint
46 | # rules and activating additional ones.
47 | flutter_lints: ^2.0.0
48 |
49 | # For information on the generic Dart part of this file, see the
50 | # following page: https://dart.dev/tools/pub/pubspec
51 |
52 | # The following section is specific to Flutter.
53 | flutter:
54 |
55 | # The following line ensures that the Material Icons font is
56 | # included with your application, so that you can use the icons in
57 | # the material Icons class.
58 | uses-material-design: true
59 |
60 | # To add assets to your application, add an assets section, like this:
61 | # assets:
62 | # - images/a_dot_burr.jpeg
63 | # - images/a_dot_ham.jpeg
64 |
65 | # An image asset can refer to one or more resolution-specific "variants", see
66 | # https://flutter.dev/assets-and-images/#resolution-aware.
67 |
68 | # For details regarding adding assets from package dependencies, see
69 | # https://flutter.dev/assets-and-images/#from-packages
70 |
71 | # To add custom fonts to your application, add a fonts section here,
72 | # in this "flutter" section. Each entry in this list should have a
73 | # "family" key with the font family name, and a "fonts" key with a
74 | # list giving the asset and other descriptors for the font. For
75 | # example:
76 | # fonts:
77 | # - family: Schyler
78 | # fonts:
79 | # - asset: fonts/Schyler-Regular.ttf
80 | # - asset: fonts/Schyler-Italic.ttf
81 | # style: italic
82 | # - family: Trajan Pro
83 | # fonts:
84 | # - asset: fonts/TrajanPro.ttf
85 | # - asset: fonts/TrajanPro_Bold.ttf
86 | # weight: 700
87 | #
88 | # For details regarding fonts from package dependencies,
89 | # see https://flutter.dev/custom-fonts/#from-packages
90 |
--------------------------------------------------------------------------------
/example/test/widget_test.dart:
--------------------------------------------------------------------------------
1 | // This is a basic Flutter widget test.
2 | //
3 | // To perform an interaction with a widget in your test, use the WidgetTester
4 | // utility that Flutter provides. For example, you can send tap and scroll
5 | // gestures. You can also use WidgetTester to find child widgets in the widget
6 | // tree, read text, and verify that the values of widget properties are correct.
7 |
8 | import 'package:flutter/material.dart';
9 | import 'package:flutter_test/flutter_test.dart';
10 |
11 | import 'package:screen_text_extractor_example/main.dart';
12 |
13 | void main() {
14 | testWidgets('Verify Platform version', (WidgetTester tester) async {
15 | // Build our app and trigger a frame.
16 | await tester.pumpWidget(const MyApp());
17 |
18 | // Verify that platform version is retrieved.
19 | expect(
20 | find.byWidgetPredicate(
21 | (Widget widget) =>
22 | widget is Text && widget.data!.startsWith('Running on:'),
23 | ),
24 | findsOneWidget,
25 | );
26 | });
27 | }
28 |
--------------------------------------------------------------------------------
/example/windows/.gitignore:
--------------------------------------------------------------------------------
1 | flutter/ephemeral/
2 |
3 | # Visual Studio user-specific files.
4 | *.suo
5 | *.user
6 | *.userosscache
7 | *.sln.docstates
8 |
9 | # Visual Studio build-related files.
10 | x64/
11 | x86/
12 |
13 | # Visual Studio cache files
14 | # files ending in .cache can be ignored
15 | *.[Cc]ache
16 | # but keep track of directories ending in .cache
17 | !*.[Cc]ache/
18 |
--------------------------------------------------------------------------------
/example/windows/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.15)
2 | project(screen_text_extractor_example LANGUAGES CXX)
3 |
4 | set(BINARY_NAME "screen_text_extractor_example")
5 |
6 | cmake_policy(SET CMP0063 NEW)
7 |
8 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
9 |
10 | # Configure build options.
11 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
12 | if(IS_MULTICONFIG)
13 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release"
14 | CACHE STRING "" FORCE)
15 | else()
16 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
17 | set(CMAKE_BUILD_TYPE "Debug" CACHE
18 | STRING "Flutter build mode" FORCE)
19 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
20 | "Debug" "Profile" "Release")
21 | endif()
22 | endif()
23 |
24 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
25 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
26 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}")
27 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}")
28 |
29 | # Use Unicode for all projects.
30 | add_definitions(-DUNICODE -D_UNICODE)
31 |
32 | # Compilation settings that should be applied to most targets.
33 | function(APPLY_STANDARD_SETTINGS TARGET)
34 | target_compile_features(${TARGET} PUBLIC cxx_std_17)
35 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
36 | target_compile_options(${TARGET} PRIVATE /EHsc)
37 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
38 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>")
39 | endfunction()
40 |
41 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
42 |
43 | # Flutter library and tool build rules.
44 | add_subdirectory(${FLUTTER_MANAGED_DIR})
45 |
46 | # Application build
47 | add_subdirectory("runner")
48 |
49 | # Generated plugin build rules, which manage building the plugins and adding
50 | # them to the application.
51 | include(flutter/generated_plugins.cmake)
52 |
53 |
54 | # === Installation ===
55 | # Support files are copied into place next to the executable, so that it can
56 | # run in place. This is done instead of making a separate bundle (as on Linux)
57 | # so that building and running from within Visual Studio will work.
58 | set(BUILD_BUNDLE_DIR "$")
59 | # Make the "install" step default, as it's required to run.
60 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
61 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
62 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
63 | endif()
64 |
65 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
66 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}")
67 |
68 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
69 | COMPONENT Runtime)
70 |
71 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
72 | COMPONENT Runtime)
73 |
74 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
75 | COMPONENT Runtime)
76 |
77 | if(PLUGIN_BUNDLED_LIBRARIES)
78 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
79 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
80 | COMPONENT Runtime)
81 | endif()
82 |
83 | # Fully re-copy the assets directory on each build to avoid having stale files
84 | # from a previous install.
85 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
86 | install(CODE "
87 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
88 | " COMPONENT Runtime)
89 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
90 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
91 |
92 | # Install the AOT library on non-Debug builds only.
93 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
94 | CONFIGURATIONS Profile;Release
95 | COMPONENT Runtime)
96 |
--------------------------------------------------------------------------------
/example/windows/flutter/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.15)
2 |
3 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
4 |
5 | # Configuration provided via flutter tool.
6 | include(${EPHEMERAL_DIR}/generated_config.cmake)
7 |
8 | # TODO: Move the rest of this into files in ephemeral. See
9 | # https://github.com/flutter/flutter/issues/57146.
10 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")
11 |
12 | # === Flutter Library ===
13 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")
14 |
15 | # Published to parent scope for install step.
16 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
17 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
18 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
19 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE)
20 |
21 | list(APPEND FLUTTER_LIBRARY_HEADERS
22 | "flutter_export.h"
23 | "flutter_windows.h"
24 | "flutter_messenger.h"
25 | "flutter_plugin_registrar.h"
26 | "flutter_texture_registrar.h"
27 | )
28 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/")
29 | add_library(flutter INTERFACE)
30 | target_include_directories(flutter INTERFACE
31 | "${EPHEMERAL_DIR}"
32 | )
33 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib")
34 | add_dependencies(flutter flutter_assemble)
35 |
36 | # === Wrapper ===
37 | list(APPEND CPP_WRAPPER_SOURCES_CORE
38 | "core_implementations.cc"
39 | "standard_codec.cc"
40 | )
41 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/")
42 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN
43 | "plugin_registrar.cc"
44 | )
45 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/")
46 | list(APPEND CPP_WRAPPER_SOURCES_APP
47 | "flutter_engine.cc"
48 | "flutter_view_controller.cc"
49 | )
50 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/")
51 |
52 | # Wrapper sources needed for a plugin.
53 | add_library(flutter_wrapper_plugin STATIC
54 | ${CPP_WRAPPER_SOURCES_CORE}
55 | ${CPP_WRAPPER_SOURCES_PLUGIN}
56 | )
57 | apply_standard_settings(flutter_wrapper_plugin)
58 | set_target_properties(flutter_wrapper_plugin PROPERTIES
59 | POSITION_INDEPENDENT_CODE ON)
60 | set_target_properties(flutter_wrapper_plugin PROPERTIES
61 | CXX_VISIBILITY_PRESET hidden)
62 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter)
63 | target_include_directories(flutter_wrapper_plugin PUBLIC
64 | "${WRAPPER_ROOT}/include"
65 | )
66 | add_dependencies(flutter_wrapper_plugin flutter_assemble)
67 |
68 | # Wrapper sources needed for the runner.
69 | add_library(flutter_wrapper_app STATIC
70 | ${CPP_WRAPPER_SOURCES_CORE}
71 | ${CPP_WRAPPER_SOURCES_APP}
72 | )
73 | apply_standard_settings(flutter_wrapper_app)
74 | target_link_libraries(flutter_wrapper_app PUBLIC flutter)
75 | target_include_directories(flutter_wrapper_app PUBLIC
76 | "${WRAPPER_ROOT}/include"
77 | )
78 | add_dependencies(flutter_wrapper_app flutter_assemble)
79 |
80 | # === Flutter tool backend ===
81 | # _phony_ is a non-existent file to force this command to run every time,
82 | # since currently there's no way to get a full input/output list from the
83 | # flutter tool.
84 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_")
85 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE)
86 | add_custom_command(
87 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
88 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN}
89 | ${CPP_WRAPPER_SOURCES_APP}
90 | ${PHONY_OUTPUT}
91 | COMMAND ${CMAKE_COMMAND} -E env
92 | ${FLUTTER_TOOL_ENVIRONMENT}
93 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
94 | windows-x64 $
95 | VERBATIM
96 | )
97 | add_custom_target(flutter_assemble DEPENDS
98 | "${FLUTTER_LIBRARY}"
99 | ${FLUTTER_LIBRARY_HEADERS}
100 | ${CPP_WRAPPER_SOURCES_CORE}
101 | ${CPP_WRAPPER_SOURCES_PLUGIN}
102 | ${CPP_WRAPPER_SOURCES_APP}
103 | )
104 |
--------------------------------------------------------------------------------
/example/windows/flutter/generated_plugin_registrant.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #include "generated_plugin_registrant.h"
8 |
9 | #include
10 | #include
11 | #include
12 |
13 | void RegisterPlugins(flutter::PluginRegistry* registry) {
14 | ClipboardWatcherPluginRegisterWithRegistrar(
15 | registry->GetRegistrarForPlugin("ClipboardWatcherPlugin"));
16 | HotkeyManagerPluginRegisterWithRegistrar(
17 | registry->GetRegistrarForPlugin("HotkeyManagerPlugin"));
18 | ScreenTextExtractorPluginRegisterWithRegistrar(
19 | registry->GetRegistrarForPlugin("ScreenTextExtractorPlugin"));
20 | }
21 |
--------------------------------------------------------------------------------
/example/windows/flutter/generated_plugin_registrant.h:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #ifndef GENERATED_PLUGIN_REGISTRANT_
8 | #define GENERATED_PLUGIN_REGISTRANT_
9 |
10 | #include
11 |
12 | // Registers Flutter plugins.
13 | void RegisterPlugins(flutter::PluginRegistry* registry);
14 |
15 | #endif // GENERATED_PLUGIN_REGISTRANT_
16 |
--------------------------------------------------------------------------------
/example/windows/flutter/generated_plugins.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Generated file, do not edit.
3 | #
4 |
5 | list(APPEND FLUTTER_PLUGIN_LIST
6 | clipboard_watcher
7 | hotkey_manager
8 | screen_text_extractor
9 | )
10 |
11 | list(APPEND FLUTTER_FFI_PLUGIN_LIST
12 | )
13 |
14 | set(PLUGIN_BUNDLED_LIBRARIES)
15 |
16 | foreach(plugin ${FLUTTER_PLUGIN_LIST})
17 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin})
18 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
19 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $)
20 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
21 | endforeach(plugin)
22 |
23 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
24 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
25 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
26 | endforeach(ffi_plugin)
27 |
--------------------------------------------------------------------------------
/example/windows/runner/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.15)
2 | project(runner LANGUAGES CXX)
3 |
4 | add_executable(${BINARY_NAME} WIN32
5 | "flutter_window.cpp"
6 | "main.cpp"
7 | "run_loop.cpp"
8 | "utils.cpp"
9 | "win32_window.cpp"
10 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
11 | "Runner.rc"
12 | "runner.exe.manifest"
13 | )
14 | apply_standard_settings(${BINARY_NAME})
15 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
16 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
17 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
18 | add_dependencies(${BINARY_NAME} flutter_assemble)
19 |
--------------------------------------------------------------------------------
/example/windows/runner/Runner.rc:
--------------------------------------------------------------------------------
1 | // Microsoft Visual C++ generated resource script.
2 | //
3 | #pragma code_page(65001)
4 | #include "resource.h"
5 |
6 | #define APSTUDIO_READONLY_SYMBOLS
7 | /////////////////////////////////////////////////////////////////////////////
8 | //
9 | // Generated from the TEXTINCLUDE 2 resource.
10 | //
11 | #include "winres.h"
12 |
13 | /////////////////////////////////////////////////////////////////////////////
14 | #undef APSTUDIO_READONLY_SYMBOLS
15 |
16 | /////////////////////////////////////////////////////////////////////////////
17 | // English (United States) resources
18 |
19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
21 |
22 | #ifdef APSTUDIO_INVOKED
23 | /////////////////////////////////////////////////////////////////////////////
24 | //
25 | // TEXTINCLUDE
26 | //
27 |
28 | 1 TEXTINCLUDE
29 | BEGIN
30 | "resource.h\0"
31 | END
32 |
33 | 2 TEXTINCLUDE
34 | BEGIN
35 | "#include ""winres.h""\r\n"
36 | "\0"
37 | END
38 |
39 | 3 TEXTINCLUDE
40 | BEGIN
41 | "\r\n"
42 | "\0"
43 | END
44 |
45 | #endif // APSTUDIO_INVOKED
46 |
47 |
48 | /////////////////////////////////////////////////////////////////////////////
49 | //
50 | // Icon
51 | //
52 |
53 | // Icon with lowest ID value placed first to ensure application icon
54 | // remains consistent on all systems.
55 | IDI_APP_ICON ICON "resources\\app_icon.ico"
56 |
57 |
58 | /////////////////////////////////////////////////////////////////////////////
59 | //
60 | // Version
61 | //
62 |
63 | #ifdef FLUTTER_BUILD_NUMBER
64 | #define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER
65 | #else
66 | #define VERSION_AS_NUMBER 1,0,0
67 | #endif
68 |
69 | #ifdef FLUTTER_BUILD_NAME
70 | #define VERSION_AS_STRING #FLUTTER_BUILD_NAME
71 | #else
72 | #define VERSION_AS_STRING "1.0.0"
73 | #endif
74 |
75 | VS_VERSION_INFO VERSIONINFO
76 | FILEVERSION VERSION_AS_NUMBER
77 | PRODUCTVERSION VERSION_AS_NUMBER
78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
79 | #ifdef _DEBUG
80 | FILEFLAGS VS_FF_DEBUG
81 | #else
82 | FILEFLAGS 0x0L
83 | #endif
84 | FILEOS VOS__WINDOWS32
85 | FILETYPE VFT_APP
86 | FILESUBTYPE 0x0L
87 | BEGIN
88 | BLOCK "StringFileInfo"
89 | BEGIN
90 | BLOCK "040904e4"
91 | BEGIN
92 | VALUE "CompanyName", "com.example" "\0"
93 | VALUE "FileDescription", "Demonstrates how to use the screen_text_extractor plugin." "\0"
94 | VALUE "FileVersion", VERSION_AS_STRING "\0"
95 | VALUE "InternalName", "screen_text_extractor_example" "\0"
96 | VALUE "LegalCopyright", "Copyright (C) 2021 com.example. All rights reserved." "\0"
97 | VALUE "OriginalFilename", "screen_text_extractor_example.exe" "\0"
98 | VALUE "ProductName", "screen_text_extractor_example" "\0"
99 | VALUE "ProductVersion", VERSION_AS_STRING "\0"
100 | END
101 | END
102 | BLOCK "VarFileInfo"
103 | BEGIN
104 | VALUE "Translation", 0x409, 1252
105 | END
106 | END
107 |
108 | #endif // English (United States) resources
109 | /////////////////////////////////////////////////////////////////////////////
110 |
111 |
112 |
113 | #ifndef APSTUDIO_INVOKED
114 | /////////////////////////////////////////////////////////////////////////////
115 | //
116 | // Generated from the TEXTINCLUDE 3 resource.
117 | //
118 |
119 |
120 | /////////////////////////////////////////////////////////////////////////////
121 | #endif // not APSTUDIO_INVOKED
122 |
--------------------------------------------------------------------------------
/example/windows/runner/flutter_window.cpp:
--------------------------------------------------------------------------------
1 | #include "flutter_window.h"
2 |
3 | #include
4 |
5 | #include "flutter/generated_plugin_registrant.h"
6 |
7 | FlutterWindow::FlutterWindow(RunLoop* run_loop,
8 | const flutter::DartProject& project)
9 | : run_loop_(run_loop), project_(project) {}
10 |
11 | FlutterWindow::~FlutterWindow() {}
12 |
13 | bool FlutterWindow::OnCreate() {
14 | if (!Win32Window::OnCreate()) {
15 | return false;
16 | }
17 |
18 | RECT frame = GetClientArea();
19 |
20 | // The size here must match the window dimensions to avoid unnecessary surface
21 | // creation / destruction in the startup path.
22 | flutter_controller_ = std::make_unique(
23 | frame.right - frame.left, frame.bottom - frame.top, project_);
24 | // Ensure that basic setup of the controller was successful.
25 | if (!flutter_controller_->engine() || !flutter_controller_->view()) {
26 | return false;
27 | }
28 | RegisterPlugins(flutter_controller_->engine());
29 | run_loop_->RegisterFlutterInstance(flutter_controller_->engine());
30 | SetChildContent(flutter_controller_->view()->GetNativeWindow());
31 | return true;
32 | }
33 |
34 | void FlutterWindow::OnDestroy() {
35 | if (flutter_controller_) {
36 | run_loop_->UnregisterFlutterInstance(flutter_controller_->engine());
37 | flutter_controller_ = nullptr;
38 | }
39 |
40 | Win32Window::OnDestroy();
41 | }
42 |
43 | LRESULT
44 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message,
45 | WPARAM const wparam,
46 | LPARAM const lparam) noexcept {
47 | // Give Flutter, including plugins, an opportunity to handle window messages.
48 | if (flutter_controller_) {
49 | std::optional result =
50 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam,
51 | lparam);
52 | if (result) {
53 | return *result;
54 | }
55 | }
56 |
57 | switch (message) {
58 | case WM_FONTCHANGE:
59 | flutter_controller_->engine()->ReloadSystemFonts();
60 | break;
61 | }
62 |
63 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam);
64 | }
65 |
--------------------------------------------------------------------------------
/example/windows/runner/flutter_window.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_FLUTTER_WINDOW_H_
2 | #define RUNNER_FLUTTER_WINDOW_H_
3 |
4 | #include
5 | #include
6 |
7 | #include
8 |
9 | #include "run_loop.h"
10 | #include "win32_window.h"
11 |
12 | // A window that does nothing but host a Flutter view.
13 | class FlutterWindow : public Win32Window {
14 | public:
15 | // Creates a new FlutterWindow driven by the |run_loop|, hosting a
16 | // Flutter view running |project|.
17 | explicit FlutterWindow(RunLoop* run_loop,
18 | const flutter::DartProject& project);
19 | virtual ~FlutterWindow();
20 |
21 | protected:
22 | // Win32Window:
23 | bool OnCreate() override;
24 | void OnDestroy() override;
25 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam,
26 | LPARAM const lparam) noexcept override;
27 |
28 | private:
29 | // The run loop driving events for this window.
30 | RunLoop* run_loop_;
31 |
32 | // The project to run.
33 | flutter::DartProject project_;
34 |
35 | // The Flutter instance hosted by this window.
36 | std::unique_ptr flutter_controller_;
37 | };
38 |
39 | #endif // RUNNER_FLUTTER_WINDOW_H_
40 |
--------------------------------------------------------------------------------
/example/windows/runner/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "flutter_window.h"
6 | #include "run_loop.h"
7 | #include "utils.h"
8 |
9 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
10 | _In_ wchar_t *command_line, _In_ int show_command) {
11 | // Attach to console when present (e.g., 'flutter run') or create a
12 | // new console when running with a debugger.
13 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
14 | CreateAndAttachConsole();
15 | }
16 |
17 | // Initialize COM, so that it is available for use in the library and/or
18 | // plugins.
19 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
20 |
21 | RunLoop run_loop;
22 |
23 | flutter::DartProject project(L"data");
24 |
25 | std::vector command_line_arguments =
26 | GetCommandLineArguments();
27 |
28 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
29 |
30 | FlutterWindow window(&run_loop, project);
31 | Win32Window::Point origin(10, 10);
32 | Win32Window::Size size(1280, 720);
33 | if (!window.CreateAndShow(L"screen_text_extractor_example", origin, size)) {
34 | return EXIT_FAILURE;
35 | }
36 | window.SetQuitOnClose(true);
37 |
38 | run_loop.Run();
39 |
40 | ::CoUninitialize();
41 | return EXIT_SUCCESS;
42 | }
43 |
--------------------------------------------------------------------------------
/example/windows/runner/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Visual C++ generated include file.
3 | // Used by Runner.rc
4 | //
5 | #define IDI_APP_ICON 101
6 |
7 | // Next default values for new objects
8 | //
9 | #ifdef APSTUDIO_INVOKED
10 | #ifndef APSTUDIO_READONLY_SYMBOLS
11 | #define _APS_NEXT_RESOURCE_VALUE 102
12 | #define _APS_NEXT_COMMAND_VALUE 40001
13 | #define _APS_NEXT_CONTROL_VALUE 1001
14 | #define _APS_NEXT_SYMED_VALUE 101
15 | #endif
16 | #endif
17 |
--------------------------------------------------------------------------------
/example/windows/runner/resources/app_icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leanflutter/screen_text_extractor/787279f829d0d521eb3690f6d4c03fe83ec1cbb7/example/windows/runner/resources/app_icon.ico
--------------------------------------------------------------------------------
/example/windows/runner/run_loop.cpp:
--------------------------------------------------------------------------------
1 | #include "run_loop.h"
2 |
3 | #include
4 |
5 | #include
6 |
7 | RunLoop::RunLoop() {}
8 |
9 | RunLoop::~RunLoop() {}
10 |
11 | void RunLoop::Run() {
12 | bool keep_running = true;
13 | TimePoint next_flutter_event_time = TimePoint::clock::now();
14 | while (keep_running) {
15 | std::chrono::nanoseconds wait_duration =
16 | std::max(std::chrono::nanoseconds(0),
17 | next_flutter_event_time - TimePoint::clock::now());
18 | ::MsgWaitForMultipleObjects(
19 | 0, nullptr, FALSE, static_cast(wait_duration.count() / 1000),
20 | QS_ALLINPUT);
21 | bool processed_events = false;
22 | MSG message;
23 | // All pending Windows messages must be processed; MsgWaitForMultipleObjects
24 | // won't return again for items left in the queue after PeekMessage.
25 | while (::PeekMessage(&message, nullptr, 0, 0, PM_REMOVE)) {
26 | processed_events = true;
27 | if (message.message == WM_QUIT) {
28 | keep_running = false;
29 | break;
30 | }
31 | ::TranslateMessage(&message);
32 | ::DispatchMessage(&message);
33 | // Allow Flutter to process messages each time a Windows message is
34 | // processed, to prevent starvation.
35 | next_flutter_event_time =
36 | std::min(next_flutter_event_time, ProcessFlutterMessages());
37 | }
38 | // If the PeekMessage loop didn't run, process Flutter messages.
39 | if (!processed_events) {
40 | next_flutter_event_time =
41 | std::min(next_flutter_event_time, ProcessFlutterMessages());
42 | }
43 | }
44 | }
45 |
46 | void RunLoop::RegisterFlutterInstance(
47 | flutter::FlutterEngine* flutter_instance) {
48 | flutter_instances_.insert(flutter_instance);
49 | }
50 |
51 | void RunLoop::UnregisterFlutterInstance(
52 | flutter::FlutterEngine* flutter_instance) {
53 | flutter_instances_.erase(flutter_instance);
54 | }
55 |
56 | RunLoop::TimePoint RunLoop::ProcessFlutterMessages() {
57 | TimePoint next_event_time = TimePoint::max();
58 | for (auto instance : flutter_instances_) {
59 | std::chrono::nanoseconds wait_duration = instance->ProcessMessages();
60 | if (wait_duration != std::chrono::nanoseconds::max()) {
61 | next_event_time =
62 | std::min(next_event_time, TimePoint::clock::now() + wait_duration);
63 | }
64 | }
65 | return next_event_time;
66 | }
67 |
--------------------------------------------------------------------------------
/example/windows/runner/run_loop.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_RUN_LOOP_H_
2 | #define RUNNER_RUN_LOOP_H_
3 |
4 | #include
5 |
6 | #include
7 | #include
8 |
9 | // A runloop that will service events for Flutter instances as well
10 | // as native messages.
11 | class RunLoop {
12 | public:
13 | RunLoop();
14 | ~RunLoop();
15 |
16 | // Prevent copying
17 | RunLoop(RunLoop const&) = delete;
18 | RunLoop& operator=(RunLoop const&) = delete;
19 |
20 | // Runs the run loop until the application quits.
21 | void Run();
22 |
23 | // Registers the given Flutter instance for event servicing.
24 | void RegisterFlutterInstance(
25 | flutter::FlutterEngine* flutter_instance);
26 |
27 | // Unregisters the given Flutter instance from event servicing.
28 | void UnregisterFlutterInstance(
29 | flutter::FlutterEngine* flutter_instance);
30 |
31 | private:
32 | using TimePoint = std::chrono::steady_clock::time_point;
33 |
34 | // Processes all currently pending messages for registered Flutter instances.
35 | TimePoint ProcessFlutterMessages();
36 |
37 | std::set flutter_instances_;
38 | };
39 |
40 | #endif // RUNNER_RUN_LOOP_H_
41 |
--------------------------------------------------------------------------------
/example/windows/runner/runner.exe.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PerMonitorV2
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/example/windows/runner/utils.cpp:
--------------------------------------------------------------------------------
1 | #include "utils.h"
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | #include
9 |
10 | void CreateAndAttachConsole() {
11 | if (::AllocConsole()) {
12 | FILE *unused;
13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) {
14 | _dup2(_fileno(stdout), 1);
15 | }
16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) {
17 | _dup2(_fileno(stdout), 2);
18 | }
19 | std::ios::sync_with_stdio();
20 | FlutterDesktopResyncOutputStreams();
21 | }
22 | }
23 |
24 | std::vector GetCommandLineArguments() {
25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use.
26 | int argc;
27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
28 | if (argv == nullptr) {
29 | return std::vector();
30 | }
31 |
32 | std::vector command_line_arguments;
33 |
34 | // Skip the first argument as it's the binary name.
35 | for (int i = 1; i < argc; i++) {
36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i]));
37 | }
38 |
39 | ::LocalFree(argv);
40 |
41 | return command_line_arguments;
42 | }
43 |
44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) {
45 | if (utf16_string == nullptr) {
46 | return std::string();
47 | }
48 | int target_length = ::WideCharToMultiByte(
49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
50 | -1, nullptr, 0, nullptr, nullptr);
51 | if (target_length == 0) {
52 | return std::string();
53 | }
54 | std::string utf8_string;
55 | utf8_string.resize(target_length);
56 | int converted_length = ::WideCharToMultiByte(
57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
58 | -1, utf8_string.data(),
59 | target_length, nullptr, nullptr);
60 | if (converted_length == 0) {
61 | return std::string();
62 | }
63 | return utf8_string;
64 | }
65 |
--------------------------------------------------------------------------------
/example/windows/runner/utils.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_UTILS_H_
2 | #define RUNNER_UTILS_H_
3 |
4 | #include
5 | #include
6 |
7 | // Creates a console for the process, and redirects stdout and stderr to
8 | // it for both the runner and the Flutter library.
9 | void CreateAndAttachConsole();
10 |
11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string
12 | // encoded in UTF-8. Returns an empty std::string on failure.
13 | std::string Utf8FromUtf16(const wchar_t* utf16_string);
14 |
15 | // Gets the command line arguments passed in as a std::vector,
16 | // encoded in UTF-8. Returns an empty std::vector on failure.
17 | std::vector GetCommandLineArguments();
18 |
19 | #endif // RUNNER_UTILS_H_
20 |
--------------------------------------------------------------------------------
/example/windows/runner/win32_window.cpp:
--------------------------------------------------------------------------------
1 | #include "win32_window.h"
2 |
3 | #include
4 |
5 | #include "resource.h"
6 |
7 | namespace {
8 |
9 | constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW";
10 |
11 | // The number of Win32Window objects that currently exist.
12 | static int g_active_window_count = 0;
13 |
14 | using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd);
15 |
16 | // Scale helper to convert logical scaler values to physical using passed in
17 | // scale factor
18 | int Scale(int source, double scale_factor) {
19 | return static_cast(source * scale_factor);
20 | }
21 |
22 | // Dynamically loads the |EnableNonClientDpiScaling| from the User32 module.
23 | // This API is only needed for PerMonitor V1 awareness mode.
24 | void EnableFullDpiSupportIfAvailable(HWND hwnd) {
25 | HMODULE user32_module = LoadLibraryA("User32.dll");
26 | if (!user32_module) {
27 | return;
28 | }
29 | auto enable_non_client_dpi_scaling =
30 | reinterpret_cast(
31 | GetProcAddress(user32_module, "EnableNonClientDpiScaling"));
32 | if (enable_non_client_dpi_scaling != nullptr) {
33 | enable_non_client_dpi_scaling(hwnd);
34 | FreeLibrary(user32_module);
35 | }
36 | }
37 |
38 | } // namespace
39 |
40 | // Manages the Win32Window's window class registration.
41 | class WindowClassRegistrar {
42 | public:
43 | ~WindowClassRegistrar() = default;
44 |
45 | // Returns the singleton registar instance.
46 | static WindowClassRegistrar* GetInstance() {
47 | if (!instance_) {
48 | instance_ = new WindowClassRegistrar();
49 | }
50 | return instance_;
51 | }
52 |
53 | // Returns the name of the window class, registering the class if it hasn't
54 | // previously been registered.
55 | const wchar_t* GetWindowClass();
56 |
57 | // Unregisters the window class. Should only be called if there are no
58 | // instances of the window.
59 | void UnregisterWindowClass();
60 |
61 | private:
62 | WindowClassRegistrar() = default;
63 |
64 | static WindowClassRegistrar* instance_;
65 |
66 | bool class_registered_ = false;
67 | };
68 |
69 | WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr;
70 |
71 | const wchar_t* WindowClassRegistrar::GetWindowClass() {
72 | if (!class_registered_) {
73 | WNDCLASS window_class{};
74 | window_class.hCursor = LoadCursor(nullptr, IDC_ARROW);
75 | window_class.lpszClassName = kWindowClassName;
76 | window_class.style = CS_HREDRAW | CS_VREDRAW;
77 | window_class.cbClsExtra = 0;
78 | window_class.cbWndExtra = 0;
79 | window_class.hInstance = GetModuleHandle(nullptr);
80 | window_class.hIcon =
81 | LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON));
82 | window_class.hbrBackground = 0;
83 | window_class.lpszMenuName = nullptr;
84 | window_class.lpfnWndProc = Win32Window::WndProc;
85 | RegisterClass(&window_class);
86 | class_registered_ = true;
87 | }
88 | return kWindowClassName;
89 | }
90 |
91 | void WindowClassRegistrar::UnregisterWindowClass() {
92 | UnregisterClass(kWindowClassName, nullptr);
93 | class_registered_ = false;
94 | }
95 |
96 | Win32Window::Win32Window() {
97 | ++g_active_window_count;
98 | }
99 |
100 | Win32Window::~Win32Window() {
101 | --g_active_window_count;
102 | Destroy();
103 | }
104 |
105 | bool Win32Window::CreateAndShow(const std::wstring& title,
106 | const Point& origin,
107 | const Size& size) {
108 | Destroy();
109 |
110 | const wchar_t* window_class =
111 | WindowClassRegistrar::GetInstance()->GetWindowClass();
112 |
113 | const POINT target_point = {static_cast(origin.x),
114 | static_cast(origin.y)};
115 | HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST);
116 | UINT dpi = FlutterDesktopGetDpiForMonitor(monitor);
117 | double scale_factor = dpi / 96.0;
118 |
119 | HWND window = CreateWindow(
120 | window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE,
121 | Scale(origin.x, scale_factor), Scale(origin.y, scale_factor),
122 | Scale(size.width, scale_factor), Scale(size.height, scale_factor),
123 | nullptr, nullptr, GetModuleHandle(nullptr), this);
124 |
125 | if (!window) {
126 | return false;
127 | }
128 |
129 | return OnCreate();
130 | }
131 |
132 | // static
133 | LRESULT CALLBACK Win32Window::WndProc(HWND const window,
134 | UINT const message,
135 | WPARAM const wparam,
136 | LPARAM const lparam) noexcept {
137 | if (message == WM_NCCREATE) {
138 | auto window_struct = reinterpret_cast(lparam);
139 | SetWindowLongPtr(window, GWLP_USERDATA,
140 | reinterpret_cast(window_struct->lpCreateParams));
141 |
142 | auto that = static_cast(window_struct->lpCreateParams);
143 | EnableFullDpiSupportIfAvailable(window);
144 | that->window_handle_ = window;
145 | } else if (Win32Window* that = GetThisFromHandle(window)) {
146 | return that->MessageHandler(window, message, wparam, lparam);
147 | }
148 |
149 | return DefWindowProc(window, message, wparam, lparam);
150 | }
151 |
152 | LRESULT
153 | Win32Window::MessageHandler(HWND hwnd,
154 | UINT const message,
155 | WPARAM const wparam,
156 | LPARAM const lparam) noexcept {
157 | switch (message) {
158 | case WM_DESTROY:
159 | window_handle_ = nullptr;
160 | Destroy();
161 | if (quit_on_close_) {
162 | PostQuitMessage(0);
163 | }
164 | return 0;
165 |
166 | case WM_DPICHANGED: {
167 | auto newRectSize = reinterpret_cast(lparam);
168 | LONG newWidth = newRectSize->right - newRectSize->left;
169 | LONG newHeight = newRectSize->bottom - newRectSize->top;
170 |
171 | SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth,
172 | newHeight, SWP_NOZORDER | SWP_NOACTIVATE);
173 |
174 | return 0;
175 | }
176 | case WM_SIZE: {
177 | RECT rect = GetClientArea();
178 | if (child_content_ != nullptr) {
179 | // Size and position the child window.
180 | MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left,
181 | rect.bottom - rect.top, TRUE);
182 | }
183 | return 0;
184 | }
185 |
186 | case WM_ACTIVATE:
187 | if (child_content_ != nullptr) {
188 | SetFocus(child_content_);
189 | }
190 | return 0;
191 | }
192 |
193 | return DefWindowProc(window_handle_, message, wparam, lparam);
194 | }
195 |
196 | void Win32Window::Destroy() {
197 | OnDestroy();
198 |
199 | if (window_handle_) {
200 | DestroyWindow(window_handle_);
201 | window_handle_ = nullptr;
202 | }
203 | if (g_active_window_count == 0) {
204 | WindowClassRegistrar::GetInstance()->UnregisterWindowClass();
205 | }
206 | }
207 |
208 | Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept {
209 | return reinterpret_cast(
210 | GetWindowLongPtr(window, GWLP_USERDATA));
211 | }
212 |
213 | void Win32Window::SetChildContent(HWND content) {
214 | child_content_ = content;
215 | SetParent(content, window_handle_);
216 | RECT frame = GetClientArea();
217 |
218 | MoveWindow(content, frame.left, frame.top, frame.right - frame.left,
219 | frame.bottom - frame.top, true);
220 |
221 | SetFocus(child_content_);
222 | }
223 |
224 | RECT Win32Window::GetClientArea() {
225 | RECT frame;
226 | GetClientRect(window_handle_, &frame);
227 | return frame;
228 | }
229 |
230 | HWND Win32Window::GetHandle() {
231 | return window_handle_;
232 | }
233 |
234 | void Win32Window::SetQuitOnClose(bool quit_on_close) {
235 | quit_on_close_ = quit_on_close;
236 | }
237 |
238 | bool Win32Window::OnCreate() {
239 | // No-op; provided for subclasses.
240 | return true;
241 | }
242 |
243 | void Win32Window::OnDestroy() {
244 | // No-op; provided for subclasses.
245 | }
246 |
--------------------------------------------------------------------------------
/example/windows/runner/win32_window.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_WIN32_WINDOW_H_
2 | #define RUNNER_WIN32_WINDOW_H_
3 |
4 | #include
5 |
6 | #include
7 | #include
8 | #include
9 |
10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be
11 | // inherited from by classes that wish to specialize with custom
12 | // rendering and input handling
13 | class Win32Window {
14 | public:
15 | struct Point {
16 | unsigned int x;
17 | unsigned int y;
18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {}
19 | };
20 |
21 | struct Size {
22 | unsigned int width;
23 | unsigned int height;
24 | Size(unsigned int width, unsigned int height)
25 | : width(width), height(height) {}
26 | };
27 |
28 | Win32Window();
29 | virtual ~Win32Window();
30 |
31 | // Creates and shows a win32 window with |title| and position and size using
32 | // |origin| and |size|. New windows are created on the default monitor. Window
33 | // sizes are specified to the OS in physical pixels, hence to ensure a
34 | // consistent size to will treat the width height passed in to this function
35 | // as logical pixels and scale to appropriate for the default monitor. Returns
36 | // true if the window was created successfully.
37 | bool CreateAndShow(const std::wstring& title,
38 | const Point& origin,
39 | const Size& size);
40 |
41 | // Release OS resources associated with window.
42 | void Destroy();
43 |
44 | // Inserts |content| into the window tree.
45 | void SetChildContent(HWND content);
46 |
47 | // Returns the backing Window handle to enable clients to set icon and other
48 | // window properties. Returns nullptr if the window has been destroyed.
49 | HWND GetHandle();
50 |
51 | // If true, closing this window will quit the application.
52 | void SetQuitOnClose(bool quit_on_close);
53 |
54 | // Return a RECT representing the bounds of the current client area.
55 | RECT GetClientArea();
56 |
57 | protected:
58 | // Processes and route salient window messages for mouse handling,
59 | // size change and DPI. Delegates handling of these to member overloads that
60 | // inheriting classes can handle.
61 | virtual LRESULT MessageHandler(HWND window,
62 | UINT const message,
63 | WPARAM const wparam,
64 | LPARAM const lparam) noexcept;
65 |
66 | // Called when CreateAndShow is called, allowing subclass window-related
67 | // setup. Subclasses should return false if setup fails.
68 | virtual bool OnCreate();
69 |
70 | // Called when Destroy is called.
71 | virtual void OnDestroy();
72 |
73 | private:
74 | friend class WindowClassRegistrar;
75 |
76 | // OS callback called by message pump. Handles the WM_NCCREATE message which
77 | // is passed when the non-client area is being created and enables automatic
78 | // non-client DPI scaling so that the non-client area automatically
79 | // responsponds to changes in DPI. All other messages are handled by
80 | // MessageHandler.
81 | static LRESULT CALLBACK WndProc(HWND const window,
82 | UINT const message,
83 | WPARAM const wparam,
84 | LPARAM const lparam) noexcept;
85 |
86 | // Retrieves a class instance pointer for |window|
87 | static Win32Window* GetThisFromHandle(HWND const window) noexcept;
88 |
89 | bool quit_on_close_ = false;
90 |
91 | // window handle for top level window.
92 | HWND window_handle_ = nullptr;
93 |
94 | // window handle for hosted content.
95 | HWND child_content_ = nullptr;
96 | };
97 |
98 | #endif // RUNNER_WIN32_WINDOW_H_
99 |
--------------------------------------------------------------------------------
/lib/screen_text_extractor.dart:
--------------------------------------------------------------------------------
1 | library screen_text_extractor;
2 |
3 | export 'src/clipboard_once_watcher.dart';
4 | export 'src/extract_mode.dart';
5 | export 'src/extracted_data.dart';
6 | export 'src/screen_text_extractor.dart';
7 |
--------------------------------------------------------------------------------
/lib/src/clipboard_once_watcher.dart:
--------------------------------------------------------------------------------
1 | import 'package:clipboard_watcher/clipboard_watcher.dart';
2 | import 'package:flutter/material.dart';
3 |
4 | class ClipboardOnceWatcher with ClipboardListener {
5 | VoidCallback? onChange;
6 |
7 | Future watch({
8 | VoidCallback? onChange,
9 | VoidCallback? onTimeout,
10 | }) async {
11 | this.onChange = onChange;
12 | Future.delayed(const Duration(milliseconds: 3000)).then((value) {
13 | if (onTimeout != null) {
14 | onTimeout();
15 | }
16 | });
17 | clipboardWatcher.addListener(this);
18 | await clipboardWatcher.start();
19 | }
20 |
21 | Future stop() async {
22 | clipboardWatcher.removeListener(this);
23 | await clipboardWatcher.stop();
24 | }
25 |
26 | @override
27 | void onClipboardChanged() async {
28 | await stop();
29 | if (onChange != null) {
30 | onChange!();
31 | onChange = null;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/lib/src/extract_mode.dart:
--------------------------------------------------------------------------------
1 | enum ExtractMode {
2 | clipboard,
3 | screenSelection,
4 | }
5 |
--------------------------------------------------------------------------------
/lib/src/extracted_data.dart:
--------------------------------------------------------------------------------
1 | class ExtractedData {
2 | String? text;
3 |
4 | ExtractedData({
5 | this.text,
6 | });
7 |
8 | factory ExtractedData.fromJson(Map json) {
9 | return ExtractedData(
10 | text: json['text'],
11 | );
12 | }
13 |
14 | Map toJson() {
15 | return {
16 | 'text': text,
17 | }..removeWhere((key, value) => value == null);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/lib/src/screen_text_extractor.dart:
--------------------------------------------------------------------------------
1 | import 'dart:async';
2 | import 'dart:io';
3 |
4 | import 'package:flutter/foundation.dart';
5 | import 'package:flutter/services.dart';
6 |
7 | import 'extract_mode.dart';
8 | import 'extracted_data.dart';
9 | import 'clipboard_once_watcher.dart';
10 |
11 | class ScreenTextExtractor {
12 | ScreenTextExtractor._();
13 |
14 | /// The shared instance of [ScreenTextExtractor].
15 | static final ScreenTextExtractor instance = ScreenTextExtractor._();
16 |
17 | final MethodChannel _channel = const MethodChannel('screen_text_extractor');
18 |
19 | final ClipboardOnceWatcher _clipboardOnceWatcher = ClipboardOnceWatcher();
20 |
21 | Future isAccessAllowed() async {
22 | if (!kIsWeb && Platform.isMacOS) {
23 | return await _channel.invokeMethod('isAccessAllowed');
24 | }
25 | return true;
26 | }
27 |
28 | Future requestAccess({
29 | bool onlyOpenPrefPane = false,
30 | }) async {
31 | if (!kIsWeb && Platform.isMacOS) {
32 | final Map arguments = {
33 | 'onlyOpenPrefPane': onlyOpenPrefPane,
34 | };
35 | await _channel.invokeMethod('requestAccess', arguments);
36 | }
37 | }
38 |
39 | Future extract({
40 | ExtractMode mode = ExtractMode.clipboard,
41 | }) async {
42 | if (mode == ExtractMode.clipboard) {
43 | return await _extractFromClipboard();
44 | } else if (mode == ExtractMode.screenSelection) {
45 | return await _extractFromScreenSelection();
46 | } else {
47 | throw ArgumentError('Invalid extract mode: $mode');
48 | }
49 | }
50 |
51 | Future _simulateCtrlCKeyPress() async {
52 | return await _channel.invokeMethod('simulateCtrlCKeyPress', {});
53 | }
54 |
55 | Future _extractFromClipboard() async {
56 | ClipboardData? d = await Clipboard.getData(Clipboard.kTextPlain);
57 | if (d == null) return null;
58 | return ExtractedData(text: d.text ?? '');
59 | }
60 |
61 | Future _extractFromScreenSelection() async {
62 | if (Platform.isWindows || Platform.isMacOS) {
63 | Completer completer = Completer();
64 |
65 | await _clipboardOnceWatcher.watch(
66 | onChange: () {
67 | if (completer.isCompleted) return;
68 | completer.complete(_extractFromClipboard());
69 | },
70 | onTimeout: () {
71 | if (completer.isCompleted) return;
72 | completer.complete(null);
73 | },
74 | );
75 |
76 | // 通过模拟按下 Ctrl+C 快捷键以达到取词的目的。
77 | await _simulateCtrlCKeyPress();
78 | return completer.future;
79 | } else {
80 | final Map resultData = await _channel.invokeMethod(
81 | 'extractFromScreenSelection',
82 | );
83 |
84 | return ExtractedData.fromJson(
85 | Map.from(resultData),
86 | );
87 | }
88 | }
89 | }
90 |
91 | final screenTextExtractor = ScreenTextExtractor.instance;
92 |
--------------------------------------------------------------------------------
/linux/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10)
2 | set(PROJECT_NAME "screen_text_extractor")
3 | project(${PROJECT_NAME} LANGUAGES CXX)
4 |
5 | # This value is used when generating builds using this plugin, so it must
6 | # not be changed
7 | set(PLUGIN_NAME "screen_text_extractor_plugin")
8 |
9 | add_library(${PLUGIN_NAME} SHARED
10 | "screen_text_extractor_plugin.cc"
11 | )
12 | apply_standard_settings(${PLUGIN_NAME})
13 | set_target_properties(${PLUGIN_NAME} PROPERTIES
14 | CXX_VISIBILITY_PRESET hidden)
15 | target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
16 | target_include_directories(${PLUGIN_NAME} INTERFACE
17 | "${CMAKE_CURRENT_SOURCE_DIR}/include")
18 | target_link_libraries(${PLUGIN_NAME} PRIVATE flutter)
19 | target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK)
20 |
21 | # List of absolute paths to libraries that should be bundled with the plugin
22 | set(screen_text_extractor_bundled_libraries
23 | ""
24 | PARENT_SCOPE
25 | )
26 |
--------------------------------------------------------------------------------
/linux/include/screen_text_extractor/screen_text_extractor_plugin.h:
--------------------------------------------------------------------------------
1 | #ifndef FLUTTER_PLUGIN_SCREEN_TEXT_EXTRACTOR_PLUGIN_H_
2 | #define FLUTTER_PLUGIN_SCREEN_TEXT_EXTRACTOR_PLUGIN_H_
3 |
4 | #include
5 |
6 | G_BEGIN_DECLS
7 |
8 | #ifdef FLUTTER_PLUGIN_IMPL
9 | #define FLUTTER_PLUGIN_EXPORT __attribute__((visibility("default")))
10 | #else
11 | #define FLUTTER_PLUGIN_EXPORT
12 | #endif
13 |
14 | typedef struct _ScreenTextExtractorPlugin ScreenTextExtractorPlugin;
15 | typedef struct {
16 | GObjectClass parent_class;
17 | } ScreenTextExtractorPluginClass;
18 |
19 | FLUTTER_PLUGIN_EXPORT GType screen_text_extractor_plugin_get_type();
20 |
21 | FLUTTER_PLUGIN_EXPORT void screen_text_extractor_plugin_register_with_registrar(
22 | FlPluginRegistrar* registrar);
23 |
24 | G_END_DECLS
25 |
26 | #endif // FLUTTER_PLUGIN_SCREEN_TEXT_EXTRACTOR_PLUGIN_H_
27 |
--------------------------------------------------------------------------------
/linux/screen_text_extractor_plugin.cc:
--------------------------------------------------------------------------------
1 | #include "include/screen_text_extractor/screen_text_extractor_plugin.h"
2 |
3 | #include
4 | #include
5 | #include
6 |
7 | #include
8 |
9 | #define SCREEN_TEXT_EXTRACTOR_PLUGIN(obj) \
10 | (G_TYPE_CHECK_INSTANCE_CAST((obj), screen_text_extractor_plugin_get_type(), \
11 | ScreenTextExtractorPlugin))
12 |
13 | struct _ScreenTextExtractorPlugin
14 | {
15 | GObject parent_instance;
16 | };
17 |
18 | G_DEFINE_TYPE(ScreenTextExtractorPlugin, screen_text_extractor_plugin, g_object_get_type())
19 |
20 | static FlMethodResponse *extract_from_screen_selection(ScreenTextExtractorPlugin *self,
21 | FlValue *args)
22 | {
23 | GtkClipboard *clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
24 | gchar *text = gtk_clipboard_wait_for_text(clipboard);
25 |
26 | g_autoptr(FlValue) result_data = fl_value_new_map();
27 | fl_value_set_string_take(result_data, "text", fl_value_new_string(text));
28 |
29 | return FL_METHOD_RESPONSE(fl_method_success_response_new(result_data));
30 | }
31 |
32 | // Called when a method call is received from Flutter.
33 | static void screen_text_extractor_plugin_handle_method_call(
34 | ScreenTextExtractorPlugin *self,
35 | FlMethodCall *method_call)
36 | {
37 | g_autoptr(FlMethodResponse) response = nullptr;
38 |
39 | const gchar *method = fl_method_call_get_name(method_call);
40 | FlValue *args = fl_method_call_get_args(method_call);
41 |
42 | if (strcmp(method, "extractFromScreenSelection") == 0)
43 | {
44 | response = extract_from_screen_selection(self, args);
45 | }
46 | else
47 | {
48 | response = FL_METHOD_RESPONSE(fl_method_not_implemented_response_new());
49 | }
50 |
51 | fl_method_call_respond(method_call, response, nullptr);
52 | }
53 |
54 | static void screen_text_extractor_plugin_dispose(GObject *object)
55 | {
56 | G_OBJECT_CLASS(screen_text_extractor_plugin_parent_class)->dispose(object);
57 | }
58 |
59 | static void screen_text_extractor_plugin_class_init(ScreenTextExtractorPluginClass *klass)
60 | {
61 | G_OBJECT_CLASS(klass)->dispose = screen_text_extractor_plugin_dispose;
62 | }
63 |
64 | static void screen_text_extractor_plugin_init(ScreenTextExtractorPlugin *self) {}
65 |
66 | static void method_call_cb(FlMethodChannel *channel, FlMethodCall *method_call,
67 | gpointer user_data)
68 | {
69 | ScreenTextExtractorPlugin *plugin = SCREEN_TEXT_EXTRACTOR_PLUGIN(user_data);
70 | screen_text_extractor_plugin_handle_method_call(plugin, method_call);
71 | }
72 |
73 | void screen_text_extractor_plugin_register_with_registrar(FlPluginRegistrar *registrar)
74 | {
75 | ScreenTextExtractorPlugin *plugin = SCREEN_TEXT_EXTRACTOR_PLUGIN(
76 | g_object_new(screen_text_extractor_plugin_get_type(), nullptr));
77 |
78 | g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
79 | g_autoptr(FlMethodChannel) channel =
80 | fl_method_channel_new(fl_plugin_registrar_get_messenger(registrar),
81 | "screen_text_extractor",
82 | FL_METHOD_CODEC(codec));
83 | fl_method_channel_set_method_call_handler(channel, method_call_cb,
84 | g_object_ref(plugin),
85 | g_object_unref);
86 |
87 | g_object_unref(plugin);
88 | }
89 |
--------------------------------------------------------------------------------
/macos/Classes/ScreenTextExtractorPlugin.swift:
--------------------------------------------------------------------------------
1 | import Carbon
2 | import Cocoa
3 | import FlutterMacOS
4 |
5 | public class ScreenTextExtractorPlugin: NSObject, FlutterPlugin {
6 | public static func register(with registrar: FlutterPluginRegistrar) {
7 | let channel = FlutterMethodChannel(name: "screen_text_extractor", binaryMessenger: registrar.messenger)
8 | let instance = ScreenTextExtractorPlugin()
9 | registrar.addMethodCallDelegate(instance, channel: channel)
10 | }
11 |
12 | public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
13 | switch call.method {
14 | case "isAccessAllowed":
15 | isAccessAllowed(call, result: result)
16 | break
17 | case "requestAccess":
18 | requestAccess(call, result: result)
19 | break
20 | case "simulateCtrlCKeyPress":
21 | simulateCtrlCKeyPress(call, result: result)
22 | break
23 | default:
24 | result(FlutterMethodNotImplemented)
25 | }
26 | }
27 |
28 | public func isAccessAllowed(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
29 | result(AXIsProcessTrusted())
30 | }
31 |
32 | public func requestAccess(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
33 | let args:[String: Any] = call.arguments as! [String: Any]
34 | let onlyOpenPrefPane: Bool = args["onlyOpenPrefPane"] as! Bool
35 |
36 | if (!onlyOpenPrefPane) {
37 | let options = [kAXTrustedCheckOptionPrompt.takeRetainedValue(): true] as CFDictionary
38 | AXIsProcessTrustedWithOptions(options)
39 | } else {
40 | let prefpaneUrl = URL(string: "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility")!
41 | NSWorkspace.shared.open(prefpaneUrl)
42 | }
43 | result(true)
44 | }
45 |
46 | public func simulateCtrlCKeyPress(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
47 | let eventKeyDown = CGEvent(keyboardEventSource: nil, virtualKey: CGKeyCode(UInt32(kVK_ANSI_C)), keyDown: true);
48 | eventKeyDown!.flags = CGEventFlags.maskCommand;
49 | eventKeyDown!.post(tap: CGEventTapLocation.cghidEventTap);
50 | result(true)
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/macos/screen_text_extractor.podspec:
--------------------------------------------------------------------------------
1 | #
2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
3 | # Run `pod lib lint screen_text_extractor.podspec` to validate before publishing.
4 | #
5 | Pod::Spec.new do |s|
6 | s.name = 'screen_text_extractor'
7 | s.version = '0.1.0'
8 | s.summary = 'A new flutter plugin project.'
9 | s.description = <<-DESC
10 | A new flutter plugin project.
11 | DESC
12 | s.homepage = 'http://example.com'
13 | s.license = { :file => '../LICENSE' }
14 | s.author = { 'Your Company' => 'email@example.com' }
15 | s.source = { :path => '.' }
16 | s.source_files = 'Classes/**/*'
17 | s.dependency 'FlutterMacOS'
18 |
19 | s.platform = :osx, '10.11'
20 | s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
21 | s.swift_version = '5.0'
22 | end
23 |
--------------------------------------------------------------------------------
/pubspec.lock:
--------------------------------------------------------------------------------
1 | # Generated by pub
2 | # See https://dart.dev/tools/pub/glossary#lockfile
3 | packages:
4 | args:
5 | dependency: transitive
6 | description:
7 | name: args
8 | sha256: "139d809800a412ebb26a3892da228b2d0ba36f0ef5d9a82166e5e52ec8d61611"
9 | url: "https://pub.dev"
10 | source: hosted
11 | version: "2.3.2"
12 | async:
13 | dependency: transitive
14 | description:
15 | name: async
16 | sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
17 | url: "https://pub.dev"
18 | source: hosted
19 | version: "2.11.0"
20 | boolean_selector:
21 | dependency: transitive
22 | description:
23 | name: boolean_selector
24 | sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
25 | url: "https://pub.dev"
26 | source: hosted
27 | version: "2.1.1"
28 | build_config:
29 | dependency: transitive
30 | description:
31 | name: build_config
32 | sha256: bf80fcfb46a29945b423bd9aad884590fb1dc69b330a4d4700cac476af1708d1
33 | url: "https://pub.dev"
34 | source: hosted
35 | version: "1.1.1"
36 | characters:
37 | dependency: transitive
38 | description:
39 | name: characters
40 | sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
41 | url: "https://pub.dev"
42 | source: hosted
43 | version: "1.3.0"
44 | checked_yaml:
45 | dependency: transitive
46 | description:
47 | name: checked_yaml
48 | sha256: "3d1505d91afa809d177efd4eed5bb0eb65805097a1463abdd2add076effae311"
49 | url: "https://pub.dev"
50 | source: hosted
51 | version: "2.0.2"
52 | clipboard_watcher:
53 | dependency: "direct main"
54 | description:
55 | name: clipboard_watcher
56 | sha256: "2fa9c728f46962668dbc1c07870695c9163524f8dbea25dc176277d1ef1cc2bd"
57 | url: "https://pub.dev"
58 | source: hosted
59 | version: "0.2.0"
60 | clock:
61 | dependency: transitive
62 | description:
63 | name: clock
64 | sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
65 | url: "https://pub.dev"
66 | source: hosted
67 | version: "1.1.1"
68 | collection:
69 | dependency: transitive
70 | description:
71 | name: collection
72 | sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
73 | url: "https://pub.dev"
74 | source: hosted
75 | version: "1.17.1"
76 | dependency_validator:
77 | dependency: "direct dev"
78 | description:
79 | name: dependency_validator
80 | sha256: "08349175533ed0bd06eb9b6043cde66c45b2bfc7ebc222a7542cdb1324f1bf03"
81 | url: "https://pub.dev"
82 | source: hosted
83 | version: "3.2.2"
84 | fake_async:
85 | dependency: transitive
86 | description:
87 | name: fake_async
88 | sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
89 | url: "https://pub.dev"
90 | source: hosted
91 | version: "1.3.1"
92 | file:
93 | dependency: transitive
94 | description:
95 | name: file
96 | sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d"
97 | url: "https://pub.dev"
98 | source: hosted
99 | version: "6.1.4"
100 | flutter:
101 | dependency: "direct main"
102 | description: flutter
103 | source: sdk
104 | version: "0.0.0"
105 | flutter_lints:
106 | dependency: "direct dev"
107 | description:
108 | name: flutter_lints
109 | sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c
110 | url: "https://pub.dev"
111 | source: hosted
112 | version: "2.0.1"
113 | flutter_test:
114 | dependency: "direct dev"
115 | description: flutter
116 | source: sdk
117 | version: "0.0.0"
118 | glob:
119 | dependency: transitive
120 | description:
121 | name: glob
122 | sha256: "4515b5b6ddb505ebdd242a5f2cc5d22d3d6a80013789debfbda7777f47ea308c"
123 | url: "https://pub.dev"
124 | source: hosted
125 | version: "2.1.1"
126 | io:
127 | dependency: transitive
128 | description:
129 | name: io
130 | sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e"
131 | url: "https://pub.dev"
132 | source: hosted
133 | version: "1.0.4"
134 | js:
135 | dependency: transitive
136 | description:
137 | name: js
138 | sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
139 | url: "https://pub.dev"
140 | source: hosted
141 | version: "0.6.7"
142 | json_annotation:
143 | dependency: transitive
144 | description:
145 | name: json_annotation
146 | sha256: c33da08e136c3df0190bd5bbe51ae1df4a7d96e7954d1d7249fea2968a72d317
147 | url: "https://pub.dev"
148 | source: hosted
149 | version: "4.8.0"
150 | lints:
151 | dependency: transitive
152 | description:
153 | name: lints
154 | sha256: "5e4a9cd06d447758280a8ac2405101e0e2094d2a1dbdd3756aec3fe7775ba593"
155 | url: "https://pub.dev"
156 | source: hosted
157 | version: "2.0.1"
158 | logging:
159 | dependency: transitive
160 | description:
161 | name: logging
162 | sha256: "04094f2eb032cbb06c6f6e8d3607edcfcb0455e2bb6cbc010cb01171dcb64e6d"
163 | url: "https://pub.dev"
164 | source: hosted
165 | version: "1.1.1"
166 | matcher:
167 | dependency: transitive
168 | description:
169 | name: matcher
170 | sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
171 | url: "https://pub.dev"
172 | source: hosted
173 | version: "0.12.15"
174 | material_color_utilities:
175 | dependency: transitive
176 | description:
177 | name: material_color_utilities
178 | sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
179 | url: "https://pub.dev"
180 | source: hosted
181 | version: "0.2.0"
182 | meta:
183 | dependency: transitive
184 | description:
185 | name: meta
186 | sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
187 | url: "https://pub.dev"
188 | source: hosted
189 | version: "1.9.1"
190 | package_config:
191 | dependency: transitive
192 | description:
193 | name: package_config
194 | sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd"
195 | url: "https://pub.dev"
196 | source: hosted
197 | version: "2.1.0"
198 | path:
199 | dependency: transitive
200 | description:
201 | name: path
202 | sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
203 | url: "https://pub.dev"
204 | source: hosted
205 | version: "1.8.3"
206 | pub_semver:
207 | dependency: transitive
208 | description:
209 | name: pub_semver
210 | sha256: "307de764d305289ff24ad257ad5c5793ce56d04947599ad68b3baa124105fc17"
211 | url: "https://pub.dev"
212 | source: hosted
213 | version: "2.1.3"
214 | pubspec_parse:
215 | dependency: transitive
216 | description:
217 | name: pubspec_parse
218 | sha256: "75f6614d6dde2dc68948dffbaa4fe5dae32cd700eb9fb763fe11dfb45a3c4d0a"
219 | url: "https://pub.dev"
220 | source: hosted
221 | version: "1.2.1"
222 | sky_engine:
223 | dependency: transitive
224 | description: flutter
225 | source: sdk
226 | version: "0.0.99"
227 | source_span:
228 | dependency: transitive
229 | description:
230 | name: source_span
231 | sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
232 | url: "https://pub.dev"
233 | source: hosted
234 | version: "1.9.1"
235 | stack_trace:
236 | dependency: transitive
237 | description:
238 | name: stack_trace
239 | sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
240 | url: "https://pub.dev"
241 | source: hosted
242 | version: "1.11.0"
243 | stream_channel:
244 | dependency: transitive
245 | description:
246 | name: stream_channel
247 | sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
248 | url: "https://pub.dev"
249 | source: hosted
250 | version: "2.1.1"
251 | string_scanner:
252 | dependency: transitive
253 | description:
254 | name: string_scanner
255 | sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
256 | url: "https://pub.dev"
257 | source: hosted
258 | version: "1.2.0"
259 | term_glyph:
260 | dependency: transitive
261 | description:
262 | name: term_glyph
263 | sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
264 | url: "https://pub.dev"
265 | source: hosted
266 | version: "1.2.1"
267 | test_api:
268 | dependency: transitive
269 | description:
270 | name: test_api
271 | sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb
272 | url: "https://pub.dev"
273 | source: hosted
274 | version: "0.5.1"
275 | vector_math:
276 | dependency: transitive
277 | description:
278 | name: vector_math
279 | sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
280 | url: "https://pub.dev"
281 | source: hosted
282 | version: "2.1.4"
283 | yaml:
284 | dependency: transitive
285 | description:
286 | name: yaml
287 | sha256: "23812a9b125b48d4007117254bca50abb6c712352927eece9e155207b1db2370"
288 | url: "https://pub.dev"
289 | source: hosted
290 | version: "3.1.1"
291 | sdks:
292 | dart: ">=3.0.0-0 <4.0.0"
293 | flutter: ">=3.3.0"
294 |
--------------------------------------------------------------------------------
/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: screen_text_extractor
2 | description: This plugin allows Flutter desktop apps to extract text from screen.
3 | version: 0.1.3
4 | homepage: https://github.com/leanflutter/screen_text_extractor
5 |
6 | environment:
7 | sdk: ">=2.18.0 <4.0.0"
8 | flutter: ">=3.3.0"
9 |
10 | dependencies:
11 | flutter:
12 | sdk: flutter
13 |
14 | clipboard_watcher: ^0.2.0
15 |
16 | dev_dependencies:
17 | flutter_test:
18 | sdk: flutter
19 | flutter_lints: ^2.0.0
20 |
21 | dependency_validator: ^3.0.0
22 |
23 | flutter:
24 | plugin:
25 | platforms:
26 | linux:
27 | pluginClass: ScreenTextExtractorPlugin
28 | macos:
29 | pluginClass: ScreenTextExtractorPlugin
30 | windows:
31 | pluginClass: ScreenTextExtractorPlugin
32 |
--------------------------------------------------------------------------------
/screen_text_extractor.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/test/screen_text_extractor_test.dart:
--------------------------------------------------------------------------------
1 | // import 'package:flutter/services.dart';
2 | import 'package:flutter_test/flutter_test.dart';
3 | // import 'package:screen_text_extractor/screen_text_extractor.dart';
4 |
5 | void main() {
6 | // const MethodChannel channel = MethodChannel('screen_text_extractor');
7 |
8 | TestWidgetsFlutterBinding.ensureInitialized();
9 |
10 | // setUp(() {
11 | // channel.setMockMethodCallHandler((MethodCall methodCall) async {
12 | // return '42';
13 | // });
14 | // });
15 |
16 | // tearDown(() {
17 | // channel.setMockMethodCallHandler(null);
18 | // });
19 | }
20 |
--------------------------------------------------------------------------------
/windows/.clang-format:
--------------------------------------------------------------------------------
1 | BasedOnStyle: Microsoft
2 |
--------------------------------------------------------------------------------
/windows/.gitignore:
--------------------------------------------------------------------------------
1 | flutter/
2 |
3 | # Visual Studio user-specific files.
4 | *.suo
5 | *.user
6 | *.userosscache
7 | *.sln.docstates
8 |
9 | # Visual Studio build-related files.
10 | x64/
11 | x86/
12 |
13 | # Visual Studio cache files
14 | # files ending in .cache can be ignored
15 | *.[Cc]ache
16 | # but keep track of directories ending in .cache
17 | !*.[Cc]ache/
18 |
--------------------------------------------------------------------------------
/windows/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.15)
2 | set(PROJECT_NAME "screen_text_extractor")
3 | project(${PROJECT_NAME} LANGUAGES CXX)
4 |
5 | # This value is used when generating builds using this plugin, so it must
6 | # not be changed
7 | set(PLUGIN_NAME "screen_text_extractor_plugin")
8 |
9 | add_library(${PLUGIN_NAME} SHARED
10 | "screen_text_extractor_plugin.cpp"
11 | )
12 | apply_standard_settings(${PLUGIN_NAME})
13 | set_target_properties(${PLUGIN_NAME} PROPERTIES
14 | CXX_VISIBILITY_PRESET hidden)
15 | target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
16 | target_compile_definitions(${PLUGIN_NAME} PRIVATE _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING)
17 | target_include_directories(${PLUGIN_NAME} INTERFACE
18 | "${CMAKE_CURRENT_SOURCE_DIR}/include")
19 | target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin)
20 |
21 | # List of absolute paths to libraries that should be bundled with the plugin
22 | set(screen_text_extractor_bundled_libraries
23 | ""
24 | PARENT_SCOPE
25 | )
26 |
--------------------------------------------------------------------------------
/windows/include/screen_text_extractor/screen_text_extractor_plugin.h:
--------------------------------------------------------------------------------
1 | #ifndef FLUTTER_PLUGIN_SCREEN_TEXT_EXTRACTOR_PLUGIN_H_
2 | #define FLUTTER_PLUGIN_SCREEN_TEXT_EXTRACTOR_PLUGIN_H_
3 |
4 | #include
5 |
6 | #ifdef FLUTTER_PLUGIN_IMPL
7 | #define FLUTTER_PLUGIN_EXPORT __declspec(dllexport)
8 | #else
9 | #define FLUTTER_PLUGIN_EXPORT __declspec(dllimport)
10 | #endif
11 |
12 | #if defined(__cplusplus)
13 | extern "C" {
14 | #endif
15 |
16 | FLUTTER_PLUGIN_EXPORT void ScreenTextExtractorPluginRegisterWithRegistrar(
17 | FlutterDesktopPluginRegistrarRef registrar);
18 |
19 | #if defined(__cplusplus)
20 | } // extern "C"
21 | #endif
22 |
23 | #endif // FLUTTER_PLUGIN_SCREEN_TEXT_EXTRACTOR_PLUGIN_H_
24 |
--------------------------------------------------------------------------------
/windows/screen_text_extractor_plugin.cpp:
--------------------------------------------------------------------------------
1 | #include "include/screen_text_extractor/screen_text_extractor_plugin.h"
2 |
3 | // This must be included before many other Windows headers.
4 | #include
5 |
6 | #include
7 | #include
8 | #include
9 |
10 | #include