├── .github
└── workflows
│ └── ci.yaml
├── .gitignore
├── .metadata
├── LICENSE
├── README.md
├── analysis_options.yaml
├── assets
└── calculator.desktop
├── l10n.yaml
├── lib
├── calculator.dart
├── keypad.dart
├── l10n
│ └── app_en.arb
├── main.dart
└── page.dart
├── linux
├── .gitignore
├── CMakeLists.txt
├── flutter
│ └── CMakeLists.txt
├── 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
└── RunnerTests
│ └── RunnerTests.swift
├── pubspec.yaml
├── screenshot.png
├── snap
└── snapcraft.yaml
├── test
└── calculator_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
├── runner.exe.manifest
├── utils.cpp
├── utils.h
├── win32_window.cpp
└── win32_window.h
/.github/workflows/ci.yaml:
--------------------------------------------------------------------------------
1 | name: CI
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 | pull_request:
8 | workflow_dispatch:
9 |
10 | jobs:
11 | analyze:
12 | runs-on: ubuntu-22.04
13 | steps:
14 | - uses: actions/checkout@v3
15 | - uses: subosito/flutter-action@v2
16 | - run: flutter pub get
17 | - run: flutter analyze --fatal-infos
18 |
19 | format:
20 | runs-on: ubuntu-22.04
21 | steps:
22 | - uses: actions/checkout@v3
23 | - uses: subosito/flutter-action@v2
24 | - run: flutter pub get
25 | - run: dart format --set-exit-if-changed .
26 |
27 | integration:
28 | if: ${{false}} ### TODO: add integration test
29 | runs-on: ubuntu-22.04
30 | steps:
31 | - uses: actions/checkout@v3
32 | - uses: subosito/flutter-action@v2
33 | - name: Install tools
34 | run: |
35 | sudo apt update
36 | sudo apt install -y clang cmake curl libgtk-3-dev ninja-build pkg-config unzip xvfb
37 | env:
38 | DEBIAN_FRONTEND: noninteractive
39 | - name: Set up environment
40 | run: |
41 | sudo apt install -y dbus dbus-x11 gsettings-desktop-schemas
42 | echo "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$UID/bus" >> $GITHUB_ENV
43 | echo "XDG_RUNTIME_DIR=/run/user/$UID" >> $GITHUB_ENV
44 | gsettings set org.gnome.desktop.interface gtk-theme 'Yaru'
45 | env:
46 | DEBIAN_FRONTEND: noninteractive
47 | - run: flutter pub get
48 | - name: Run flutter test integration_test
49 | run: xvfb-run -a -s '-screen 0 1024x768x24 +extension GLX' flutter test -d linux integration_test
50 |
51 | linux:
52 | runs-on: ubuntu-22.04
53 | steps:
54 | - uses: actions/checkout@v3
55 | - uses: subosito/flutter-action@v2
56 | - run: sudo apt update
57 | - run: sudo apt install -y clang cmake curl libgtk-3-dev ninja-build pkg-config unzip
58 | env:
59 | DEBIAN_FRONTEND: noninteractive
60 | - run: flutter pub get
61 | - run: flutter build linux -v
62 |
63 | macos:
64 | runs-on: macos-12
65 | steps:
66 | - uses: actions/checkout@v3
67 | - uses: subosito/flutter-action@v2
68 | - run: flutter pub get
69 | - run: flutter build macos -v
70 |
71 | snap:
72 | runs-on: ubuntu-20.04
73 | steps:
74 | - uses: actions/checkout@v3
75 | - uses: snapcore/action-build@v1
76 | id: snapcraft
77 | - uses: actions/upload-artifact@v3
78 | if: github.event_name == 'workflow_dispatch'
79 | with:
80 | name: 'snap'
81 | path: ${{steps.snapcraft.outputs.snap}}
82 |
83 | test:
84 | runs-on: ubuntu-22.04
85 | steps:
86 | - uses: actions/checkout@v3
87 | - uses: subosito/flutter-action@v2
88 | - run: sudo apt update
89 | - run: sudo apt install -y lcov
90 | env:
91 | DEBIAN_FRONTEND: noninteractive
92 | - run: flutter pub get
93 | - run: flutter test --coverage
94 | - uses: codecov/codecov-action@v3
95 | with:
96 | token: ${{secrets.CODECOV_TOKEN}}
97 |
98 | web:
99 | if: ${{false}} ### TODO: add web support
100 | runs-on: ubuntu-22.04
101 | steps:
102 | - uses: actions/checkout@v3
103 | - uses: subosito/flutter-action@v2
104 | - run: flutter pub get
105 | - run: flutter build web -v
106 |
107 | windows:
108 | runs-on: windows-2022
109 | steps:
110 | - uses: actions/checkout@v3
111 | - uses: subosito/flutter-action@v2
112 | - run: flutter pub get
113 | - run: flutter build windows -v
114 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 | migrate_working_dir/
12 |
13 | # IntelliJ related
14 | *.iml
15 | *.ipr
16 | *.iws
17 | .idea/
18 |
19 | # VS Code
20 | .vscode/
21 |
22 | # Flutter/Dart/Pub related
23 | **/doc/api/
24 | **/ios/Flutter/.last_build_id
25 | .dart_tool/
26 | .flutter-plugins
27 | .flutter-plugins-dependencies
28 | .packages
29 | .pub-cache/
30 | .pub/
31 | /build/
32 | pubspec.lock
33 |
34 | # Symbolication related
35 | app.*.symbols
36 |
37 | # Obfuscation related
38 | app.*.map.json
39 |
40 | # Android Studio will place build artifacts here
41 | /android/app/debug
42 | /android/app/profile
43 | /android/app/release
44 |
--------------------------------------------------------------------------------
/.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.
5 |
6 | version:
7 | revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
8 | channel: stable
9 |
10 | project_type: app
11 |
12 | # Tracks metadata for the flutter migrate command
13 | migration:
14 | platforms:
15 | - platform: root
16 | create_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
17 | base_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
18 | - platform: linux
19 | create_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
20 | base_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
21 | - platform: macos
22 | create_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
23 | base_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
24 | - platform: windows
25 | create_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
26 | base_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
27 |
28 | # User provided section
29 |
30 | # List of Local paths (relative to this file) that should be
31 | # ignored by the migrate tool.
32 | #
33 | # Files that are not part of the templates will be ignored by default.
34 | unmanaged_files:
35 | - 'lib/main.dart'
36 | - 'ios/Runner.xcodeproj/project.pbxproj'
37 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | TODO: Add your license here.
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Calculator
2 |
3 | This sample application is powered by [math_expressions](https://pub.dev/packages/math_expressions)
4 | and [Flutter](https://flutter.dev), a cross-platform UI toolkit by Google.
5 |
6 |
7 |
8 | ## Getting Started
9 |
10 | Follow the instructions to [install Flutter](https://docs.flutter.dev/get-started/install)
11 | and run the following commands:
12 |
13 | ```
14 | git clone https://github.com/ubuntu-flutter-community/calculator.git
15 | cd calculator
16 | flutter pub get
17 | flutter run
18 | ```
19 |
20 | ## License
21 |
22 | | **NOTE:** Remember to update the [LICENSE](LICENSE) file with the license of your choice when using this template as a starting point for your own project. |
23 | | --- |
24 |
25 | The sample code in this repository is free to use or any purpose, commercial or
26 | non-commercial, and by any means.
27 |
28 | ```
29 | This is free and unencumbered software released into the public domain.
30 |
31 | Anyone is free to copy, modify, publish, use, compile, sell, or
32 | distribute this software, either in source code form or as a compiled
33 | binary, for any purpose, commercial or non-commercial, and by any
34 | means.
35 |
36 | In jurisdictions that recognize copyright laws, the author or authors
37 | of this software dedicate any and all copyright interest in the
38 | software to the public domain. We make this dedication for the benefit
39 | of the public at large and to the detriment of our heirs and
40 | successors. We intend this dedication to be an overt act of
41 | relinquishment in perpetuity of all present and future rights to this
42 | software under copyright law.
43 |
44 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
45 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
46 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
47 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
48 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
49 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
50 | OTHER DEALINGS IN THE SOFTWARE.
51 |
52 | For more information, please refer to
53 | ```
54 |
--------------------------------------------------------------------------------
/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | include: package:flutter_lints/flutter.yaml
2 |
--------------------------------------------------------------------------------
/assets/calculator.desktop:
--------------------------------------------------------------------------------
1 | [Desktop Entry]
2 | Type=Application
3 | Version=1.0
4 | Name=Calculator
5 | Comment=Calculator example
6 | Keywords=flutter;yaru;example;
7 | Exec=calculator
8 | Terminal=false
9 | Categories=Example;
10 |
--------------------------------------------------------------------------------
/l10n.yaml:
--------------------------------------------------------------------------------
1 | arb-dir: lib/l10n
2 | template-arb-file: app_en.arb
3 | output-localization-file: app_localizations.dart
4 | nullable-getter: false
5 |
--------------------------------------------------------------------------------
/lib/calculator.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/foundation.dart';
2 | import 'package:math_expressions/math_expressions.dart';
3 |
4 | class Calculator extends ChangeNotifier {
5 | var _context = ContextModel();
6 | final _history = [];
7 |
8 | List get history => List.unmodifiable(_history);
9 |
10 | dynamic calculate(String input) {
11 | final assignment = RegExp(r'(\w+)\s*=(.+)').firstMatch(input);
12 | if (assignment != null) {
13 | final variable = assignment.group(1)!;
14 | final result = calculate(assignment.group(2)!);
15 | _context.bindVariableName(variable, Number(result));
16 | _history[_history.length - 1] = _history.last.copyWith(
17 | input: input,
18 | variable: variable,
19 | );
20 | return result;
21 | }
22 | final parser = Parser();
23 | final expression = parser.parse(input);
24 | final result = expression.evaluate(EvaluationType.REAL, _context);
25 | _history.add(Calculation(input: input, result: result));
26 | notifyListeners();
27 | return result;
28 | }
29 |
30 | void clear() {
31 | _history.clear();
32 | _context = ContextModel();
33 | notifyListeners();
34 | }
35 | }
36 |
37 | @immutable
38 | class Calculation {
39 | const Calculation({
40 | required this.input,
41 | this.variable,
42 | required this.result,
43 | });
44 |
45 | final String input;
46 | final String? variable;
47 | final dynamic result;
48 |
49 | Calculation copyWith({
50 | String? input,
51 | String? variable,
52 | dynamic result,
53 | }) {
54 | return Calculation(
55 | input: input ?? this.input,
56 | variable: variable ?? this.variable,
57 | result: result ?? this.result,
58 | );
59 | }
60 |
61 | @override
62 | bool operator ==(Object other) {
63 | if (identical(this, other)) return true;
64 | return other is Calculation &&
65 | other.input == input &&
66 | other.variable == variable &&
67 | other.result == result;
68 | }
69 |
70 | @override
71 | int get hashCode => Object.hash(input, variable, result);
72 |
73 | @override
74 | String toString() {
75 | return 'Calculation(input: $input, variable: $variable, result: $result)';
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/lib/keypad.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | class Keypad extends StatelessWidget {
4 | const Keypad({
5 | super.key,
6 | required this.onInput,
7 | required this.onDone,
8 | });
9 |
10 | final ValueChanged onInput;
11 | final VoidCallback onDone;
12 |
13 | @override
14 | Widget build(BuildContext context) {
15 | return TextFieldTapRegion(
16 | child: Column(
17 | children: [
18 | Expanded(
19 | child: Row(
20 | crossAxisAlignment: CrossAxisAlignment.stretch,
21 | children: [
22 | for (final number in ['7', '8', '9'])
23 | KeyButton.number(
24 | onPressed: () => onInput(number),
25 | label: number,
26 | ),
27 | KeyButton.operator(
28 | onPressed: () => onInput('/'),
29 | label: '/',
30 | ),
31 | ],
32 | ),
33 | ),
34 | Expanded(
35 | child: Row(
36 | crossAxisAlignment: CrossAxisAlignment.stretch,
37 | children: [
38 | for (final number in ['4', '5', '6'])
39 | KeyButton.number(
40 | onPressed: () => onInput(number),
41 | label: number,
42 | ),
43 | KeyButton.operator(
44 | onPressed: () => onInput('*'),
45 | label: '*',
46 | ),
47 | ],
48 | ),
49 | ),
50 | Expanded(
51 | child: Row(
52 | crossAxisAlignment: CrossAxisAlignment.stretch,
53 | children: [
54 | for (final number in ['1', '2', '3'])
55 | KeyButton.number(
56 | onPressed: () => onInput(number),
57 | label: number,
58 | ),
59 | KeyButton.operator(
60 | onPressed: () => onInput('+'),
61 | label: '+',
62 | ),
63 | ],
64 | ),
65 | ),
66 | Expanded(
67 | child: Row(
68 | crossAxisAlignment: CrossAxisAlignment.stretch,
69 | children: [
70 | KeyButton.number(
71 | onPressed: () => onInput('0'),
72 | label: '0',
73 | ),
74 | KeyButton.operator(
75 | onPressed: () => onInput('.'),
76 | label: '.',
77 | ),
78 | KeyButton.operator(
79 | onPressed: () => onInput('-'),
80 | label: '-',
81 | ),
82 | KeyButton(
83 | onPressed: onDone,
84 | label: '=',
85 | ),
86 | ],
87 | ),
88 | ),
89 | ],
90 | ),
91 | );
92 | }
93 | }
94 |
95 | enum KeyKind { number, operator }
96 |
97 | class KeyButton extends StatelessWidget {
98 | const KeyButton({
99 | super.key,
100 | required this.onPressed,
101 | required this.label,
102 | this.kind,
103 | });
104 |
105 | const KeyButton.number({
106 | super.key,
107 | required this.onPressed,
108 | required this.label,
109 | this.kind = KeyKind.number,
110 | });
111 |
112 | const KeyButton.operator({
113 | super.key,
114 | required this.onPressed,
115 | required this.label,
116 | this.kind = KeyKind.operator,
117 | });
118 |
119 | final VoidCallback onPressed;
120 | final String label;
121 | final KeyKind? kind;
122 |
123 | Color? backgroundColor(BuildContext context) {
124 | switch (kind) {
125 | case KeyKind.number:
126 | return Theme.of(context).focusColor;
127 | case KeyKind.operator:
128 | return Theme.of(context).hoverColor;
129 | default:
130 | return null;
131 | }
132 | }
133 |
134 | @override
135 | Widget build(BuildContext context) {
136 | return Expanded(
137 | child: Padding(
138 | padding: const EdgeInsets.all(2),
139 | child: ElevatedButton(
140 | style: ElevatedButton.styleFrom(
141 | backgroundColor: backgroundColor(context),
142 | ),
143 | onPressed: onPressed,
144 | child: Text(label),
145 | ),
146 | ),
147 | );
148 | }
149 | }
150 |
--------------------------------------------------------------------------------
/lib/l10n/app_en.arb:
--------------------------------------------------------------------------------
1 | {
2 | "windowTitle": "Calculator"
3 | }
4 |
--------------------------------------------------------------------------------
/lib/main.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_gen/gen_l10n/app_localizations.dart';
3 | import 'package:provider/provider.dart';
4 | import 'package:yaru/yaru.dart';
5 | import 'package:yaru_widgets/yaru_widgets.dart';
6 |
7 | import 'calculator.dart';
8 | import 'page.dart';
9 |
10 | Future main() async {
11 | await YaruWindowTitleBar.ensureInitialized();
12 |
13 | runApp(
14 | YaruTheme(
15 | builder: (context, yaru, child) => MaterialApp(
16 | theme: yaru.theme,
17 | darkTheme: yaru.darkTheme,
18 | debugShowCheckedModeBanner: false,
19 | localizationsDelegates: AppLocalizations.localizationsDelegates,
20 | supportedLocales: AppLocalizations.supportedLocales,
21 | builder: (context, child) => Scaffold(
22 | appBar: YaruWindowTitleBar(
23 | title: Text(AppLocalizations.of(context).windowTitle),
24 | ),
25 | body: child,
26 | ),
27 | home: ChangeNotifierProvider(
28 | create: (_) => Calculator(),
29 | child: const CalculatorPage(),
30 | ),
31 | ),
32 | ),
33 | );
34 | }
35 |
--------------------------------------------------------------------------------
/lib/page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:intl/intl.dart';
3 | import 'package:provider/provider.dart';
4 |
5 | import 'calculator.dart';
6 | import 'keypad.dart';
7 |
8 | class CalculatorPage extends StatefulWidget {
9 | const CalculatorPage({super.key});
10 |
11 | @override
12 | State createState() => _CalculatorPageState();
13 | }
14 |
15 | class _CalculatorPageState extends State {
16 | final _controller = TextEditingController();
17 | final _focusNode = FocusNode();
18 |
19 | @override
20 | void dispose() {
21 | _controller.dispose();
22 | _focusNode.dispose();
23 | super.dispose();
24 | }
25 |
26 | void calculate(String input) {
27 | final calculator = context.read();
28 | try {
29 | final result = formatResult(calculator.calculate(input));
30 | _controller.value = TextEditingValue(
31 | text: result,
32 | selection: TextSelection.collapsed(offset: result.length),
33 | );
34 | } catch (e) {
35 | final messenger = ScaffoldMessenger.of(context);
36 | messenger.hideCurrentSnackBar();
37 | messenger.showSnackBar(
38 | SnackBar(
39 | content: Text('$e'),
40 | behavior: SnackBarBehavior.floating,
41 | showCloseIcon: true,
42 | ),
43 | );
44 | } finally {
45 | _focusNode.requestFocus();
46 | }
47 | }
48 |
49 | String formatResult(dynamic number) {
50 | final pattern = NumberFormat.decimalPattern();
51 | pattern.maximumFractionDigits = 10;
52 | return pattern.format(number);
53 | }
54 |
55 | void insertText(String text) {
56 | _controller.value = _controller.value.replaced(_controller.selection, text);
57 | }
58 |
59 | void selectCalculation(Calculation calculation) {
60 | _controller.value = TextEditingValue(
61 | text: calculation.input,
62 | selection: TextSelection.collapsed(offset: calculation.input.length),
63 | );
64 | _focusNode.requestFocus();
65 | }
66 |
67 | void resetCalculator() {
68 | _controller.clear();
69 | _focusNode.requestFocus();
70 | context.read().clear();
71 | }
72 |
73 | @override
74 | Widget build(BuildContext context) {
75 | final history = context.select((Calculator m) => m.history);
76 | return Scaffold(
77 | body: Column(
78 | crossAxisAlignment: CrossAxisAlignment.stretch,
79 | children: [
80 | Expanded(
81 | child: ListView.builder(
82 | itemCount: history.length,
83 | itemBuilder: (context, index) {
84 | final calculation = history[index];
85 | return ListTile(
86 | title: Text(calculation.input),
87 | trailing: Text(
88 | formatResult(calculation.result),
89 | style: Theme.of(context).textTheme.headlineSmall,
90 | ),
91 | onTap: () => selectCalculation(calculation),
92 | );
93 | },
94 | ),
95 | ),
96 | IntrinsicHeight(
97 | child: Padding(
98 | padding: const EdgeInsets.only(left: 2, right: 2),
99 | child: Row(
100 | crossAxisAlignment: CrossAxisAlignment.stretch,
101 | children: [
102 | Expanded(
103 | flex: 3,
104 | child: Padding(
105 | padding: const EdgeInsets.all(2),
106 | child: TextField(
107 | autofocus: true,
108 | controller: _controller,
109 | focusNode: _focusNode,
110 | decoration: InputDecoration(
111 | hintText: history.isEmpty ? 'x = 1 + 1' : null,
112 | ),
113 | onSubmitted: calculate,
114 | ),
115 | ),
116 | ),
117 | KeyButton.operator(
118 | onPressed: resetCalculator,
119 | label: 'C',
120 | ),
121 | ],
122 | ),
123 | ),
124 | ),
125 | Expanded(
126 | child: Padding(
127 | padding: const EdgeInsets.only(left: 2, right: 2, bottom: 2),
128 | child: Keypad(
129 | onInput: insertText,
130 | onDone: () => calculate(_controller.text),
131 | ),
132 | ),
133 | ),
134 | ],
135 | ),
136 | );
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/linux/.gitignore:
--------------------------------------------------------------------------------
1 | flutter/ephemeral
2 | flutter/generated_plugins.cmake
3 | flutter/generated_plugin_registrant.*
4 |
--------------------------------------------------------------------------------
/linux/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Project-level configuration.
2 | cmake_minimum_required(VERSION 3.10)
3 | project(runner LANGUAGES CXX)
4 |
5 | # The name of the executable created for the application. Change this to change
6 | # the on-disk name of your application.
7 | set(BINARY_NAME "calculator")
8 | # The unique GTK application identifier for this application. See:
9 | # https://wiki.gnome.org/HowDoI/ChooseApplicationID
10 | set(APPLICATION_ID "com.example.calculator")
11 |
12 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent
13 | # versions of CMake.
14 | cmake_policy(SET CMP0063 NEW)
15 |
16 | # Load bundled libraries from the lib/ directory relative to the binary.
17 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
18 |
19 | set(USE_LIBHANDY ON)
20 |
21 | # Root filesystem for cross-building.
22 | if(FLUTTER_TARGET_PLATFORM_SYSROOT)
23 | set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT})
24 | set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
25 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
26 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
27 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
28 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
29 | endif()
30 |
31 | # Define build configuration options.
32 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
33 | set(CMAKE_BUILD_TYPE "Debug" CACHE
34 | STRING "Flutter build mode" FORCE)
35 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
36 | "Debug" "Profile" "Release")
37 | endif()
38 |
39 | # Compilation settings that should be applied to most targets.
40 | #
41 | # Be cautious about adding new options here, as plugins use this function by
42 | # default. In most cases, you should add new options to specific targets instead
43 | # of modifying this function.
44 | function(APPLY_STANDARD_SETTINGS TARGET)
45 | target_compile_features(${TARGET} PUBLIC cxx_std_14)
46 | target_compile_options(${TARGET} PRIVATE -Wall -Werror)
47 | target_compile_options(${TARGET} PRIVATE "$<$>:-O3>")
48 | target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>")
49 | endfunction()
50 |
51 | # Flutter library and tool build rules.
52 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
53 | add_subdirectory(${FLUTTER_MANAGED_DIR})
54 |
55 | # System-level dependencies.
56 | find_package(PkgConfig REQUIRED)
57 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
58 |
59 | add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
60 |
61 | # Define the application target. To change its name, change BINARY_NAME above,
62 | # not the value here, or `flutter run` will no longer work.
63 | #
64 | # Any new source files that you add to the application should be added here.
65 | add_executable(${BINARY_NAME}
66 | "main.cc"
67 | "my_application.cc"
68 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
69 | )
70 |
71 | # Apply the standard set of build settings. This can be removed for applications
72 | # that need different build settings.
73 | apply_standard_settings(${BINARY_NAME})
74 |
75 | # Add dependency libraries. Add any application-specific dependencies here.
76 | target_link_libraries(${BINARY_NAME} PRIVATE flutter)
77 | target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
78 |
79 | # Run the Flutter tool portions of the build. This must not be removed.
80 | add_dependencies(${BINARY_NAME} flutter_assemble)
81 |
82 | # Only the install-generated bundle's copy of the executable will launch
83 | # correctly, since the resources must in the right relative locations. To avoid
84 | # people trying to run the unbundled copy, put it in a subdirectory instead of
85 | # the default top-level location.
86 | set_target_properties(${BINARY_NAME}
87 | PROPERTIES
88 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
89 | )
90 |
91 | # Generated plugin build rules, which manage building the plugins and adding
92 | # them to the application.
93 | include(flutter/generated_plugins.cmake)
94 |
95 |
96 | # === Installation ===
97 | # By default, "installing" just makes a relocatable bundle in the build
98 | # directory.
99 | set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
100 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
101 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
102 | endif()
103 |
104 | # Start with a clean build bundle directory every time.
105 | install(CODE "
106 | file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\")
107 | " COMPONENT Runtime)
108 |
109 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
110 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
111 |
112 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
113 | COMPONENT Runtime)
114 |
115 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
116 | COMPONENT Runtime)
117 |
118 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
119 | COMPONENT Runtime)
120 |
121 | foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES})
122 | install(FILES "${bundled_library}"
123 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
124 | COMPONENT Runtime)
125 | endforeach(bundled_library)
126 |
127 | # Fully re-copy the assets directory on each build to avoid having stale files
128 | # from a previous install.
129 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
130 | install(CODE "
131 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
132 | " COMPONENT Runtime)
133 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
134 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
135 |
136 | # Install the AOT library on non-Debug builds only.
137 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
138 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
139 | COMPONENT Runtime)
140 | endif()
141 |
--------------------------------------------------------------------------------
/linux/flutter/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # This file controls Flutter-level build steps. It should not be edited.
2 | cmake_minimum_required(VERSION 3.10)
3 |
4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
5 |
6 | # Configuration provided via flutter tool.
7 | include(${EPHEMERAL_DIR}/generated_config.cmake)
8 |
9 | # TODO: Move the rest of this into files in ephemeral. See
10 | # https://github.com/flutter/flutter/issues/57146.
11 |
12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...),
13 | # which isn't available in 3.10.
14 | function(list_prepend LIST_NAME PREFIX)
15 | set(NEW_LIST "")
16 | foreach(element ${${LIST_NAME}})
17 | list(APPEND NEW_LIST "${PREFIX}${element}")
18 | endforeach(element)
19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE)
20 | endfunction()
21 |
22 | # === Flutter Library ===
23 | # System-level dependencies.
24 | find_package(PkgConfig REQUIRED)
25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
28 |
29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so")
30 |
31 | # Published to parent scope for install step.
32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE)
36 |
37 | list(APPEND FLUTTER_LIBRARY_HEADERS
38 | "fl_basic_message_channel.h"
39 | "fl_binary_codec.h"
40 | "fl_binary_messenger.h"
41 | "fl_dart_project.h"
42 | "fl_engine.h"
43 | "fl_json_message_codec.h"
44 | "fl_json_method_codec.h"
45 | "fl_message_codec.h"
46 | "fl_method_call.h"
47 | "fl_method_channel.h"
48 | "fl_method_codec.h"
49 | "fl_method_response.h"
50 | "fl_plugin_registrar.h"
51 | "fl_plugin_registry.h"
52 | "fl_standard_message_codec.h"
53 | "fl_standard_method_codec.h"
54 | "fl_string_codec.h"
55 | "fl_value.h"
56 | "fl_view.h"
57 | "flutter_linux.h"
58 | )
59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/")
60 | add_library(flutter INTERFACE)
61 | target_include_directories(flutter INTERFACE
62 | "${EPHEMERAL_DIR}"
63 | )
64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
65 | target_link_libraries(flutter INTERFACE
66 | PkgConfig::GTK
67 | PkgConfig::GLIB
68 | PkgConfig::GIO
69 | )
70 | add_dependencies(flutter flutter_assemble)
71 |
72 | # === Flutter tool backend ===
73 | # _phony_ is a non-existent file to force this command to run every time,
74 | # since currently there's no way to get a full input/output list from the
75 | # flutter tool.
76 | add_custom_command(
77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_
79 | COMMAND ${CMAKE_COMMAND} -E env
80 | ${FLUTTER_TOOL_ENVIRONMENT}
81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE}
83 | VERBATIM
84 | )
85 | add_custom_target(flutter_assemble DEPENDS
86 | "${FLUTTER_LIBRARY}"
87 | ${FLUTTER_LIBRARY_HEADERS}
88 | )
89 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/linux/my_application.cc:
--------------------------------------------------------------------------------
1 | #include "my_application.h"
2 |
3 | #include
4 | #include
5 |
6 | #include "flutter/generated_plugin_registrant.h"
7 |
8 | struct _MyApplication {
9 | GtkApplication parent_instance;
10 | char** dart_entrypoint_arguments;
11 | };
12 |
13 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
14 |
15 | // Implements GApplication::activate.
16 | static void my_application_activate(GApplication* application) {
17 | MyApplication* self = MY_APPLICATION(application);
18 | GtkWindow* window = GTK_WINDOW(hdy_application_window_new());
19 | gtk_window_set_application(window, GTK_APPLICATION(application));
20 |
21 | gtk_window_set_default_size(window, 360, 480);
22 | gtk_widget_show(GTK_WIDGET(window));
23 |
24 | g_autoptr(FlDartProject) project = fl_dart_project_new();
25 | fl_dart_project_set_dart_entrypoint_arguments(
26 | project, self->dart_entrypoint_arguments);
27 |
28 | FlView* view = fl_view_new(project);
29 | gtk_widget_show(GTK_WIDGET(view));
30 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));
31 |
32 | fl_register_plugins(FL_PLUGIN_REGISTRY(view));
33 |
34 | gtk_widget_grab_focus(GTK_WIDGET(view));
35 | }
36 |
37 | // Implements GApplication::local_command_line.
38 | static gboolean my_application_local_command_line(GApplication* application,
39 | gchar*** arguments,
40 | int* exit_status) {
41 | MyApplication* self = MY_APPLICATION(application);
42 | // Strip out the first argument as it is the binary name.
43 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1);
44 |
45 | g_autoptr(GError) error = nullptr;
46 | if (!g_application_register(application, nullptr, &error)) {
47 | g_warning("Failed to register: %s", error->message);
48 | *exit_status = 1;
49 | return TRUE;
50 | }
51 |
52 | g_application_activate(application);
53 | *exit_status = 0;
54 |
55 | return TRUE;
56 | }
57 |
58 | // Implements GObject::dispose.
59 | static void my_application_dispose(GObject* object) {
60 | MyApplication* self = MY_APPLICATION(object);
61 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev);
62 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object);
63 | }
64 |
65 | static void my_application_class_init(MyApplicationClass* klass) {
66 | G_APPLICATION_CLASS(klass)->activate = my_application_activate;
67 | G_APPLICATION_CLASS(klass)->local_command_line =
68 | my_application_local_command_line;
69 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose;
70 | }
71 |
72 | static void my_application_init(MyApplication* self) {}
73 |
74 | MyApplication* my_application_new() {
75 | return MY_APPLICATION(g_object_new(my_application_get_type(),
76 | "application-id", APPLICATION_ID, "flags",
77 | G_APPLICATION_NON_UNIQUE, nullptr));
78 | }
79 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/macos/.gitignore:
--------------------------------------------------------------------------------
1 | # Flutter-related
2 | **/Flutter/ephemeral/
3 | **/Pods/
4 |
5 | # Xcode-related
6 | **/dgph
7 | **/xcuserdata/
8 |
--------------------------------------------------------------------------------
/macos/Flutter/Flutter-Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
2 | #include "ephemeral/Flutter-Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/macos/Flutter/Flutter-Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
2 | #include "ephemeral/Flutter-Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/macos/Flutter/GeneratedPluginRegistrant.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | import FlutterMacOS
6 | import Foundation
7 |
8 | import screen_retriever
9 | import window_manager
10 |
11 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
12 | ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))
13 | WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin"))
14 | }
15 |
--------------------------------------------------------------------------------
/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 | target 'RunnerTests' do
35 | inherit! :search_paths
36 | end
37 | end
38 |
39 | post_install do |installer|
40 | installer.pods_project.targets.each do |target|
41 | flutter_additional_macos_build_settings(target)
42 | end
43 | end
44 |
--------------------------------------------------------------------------------
/macos/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - FlutterMacOS (1.0.0)
3 | - screen_retriever (0.0.1):
4 | - FlutterMacOS
5 | - window_manager (0.2.0):
6 | - FlutterMacOS
7 |
8 | DEPENDENCIES:
9 | - FlutterMacOS (from `Flutter/ephemeral`)
10 | - screen_retriever (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos`)
11 | - window_manager (from `Flutter/ephemeral/.symlinks/plugins/window_manager/macos`)
12 |
13 | EXTERNAL SOURCES:
14 | FlutterMacOS:
15 | :path: Flutter/ephemeral
16 | screen_retriever:
17 | :path: Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos
18 | window_manager:
19 | :path: Flutter/ephemeral/.symlinks/plugins/window_manager/macos
20 |
21 | SPEC CHECKSUMS:
22 | FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
23 | screen_retriever: 59634572a57080243dd1bf715e55b6c54f241a38
24 | window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8
25 |
26 | PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367
27 |
28 | COCOAPODS: 1.11.2
29 |
--------------------------------------------------------------------------------
/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 | 234239F48EBE7A6FDBC2EE51 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5F47ECCE1B6185F3D2FEC06C /* Pods_RunnerTests.framework */; };
25 | 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C80D7294CF71000263BE5 /* RunnerTests.swift */; };
26 | 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; };
27 | 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; };
28 | 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; };
29 | 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; };
30 | 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; };
31 | 8A436B48356ECC61603C7BAB /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D2012D051FC62D8B255CBF8 /* Pods_Runner.framework */; };
32 | /* End PBXBuildFile section */
33 |
34 | /* Begin PBXContainerItemProxy section */
35 | 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */ = {
36 | isa = PBXContainerItemProxy;
37 | containerPortal = 33CC10E52044A3C60003C045 /* Project object */;
38 | proxyType = 1;
39 | remoteGlobalIDString = 33CC10EC2044A3C60003C045;
40 | remoteInfo = Runner;
41 | };
42 | 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = {
43 | isa = PBXContainerItemProxy;
44 | containerPortal = 33CC10E52044A3C60003C045 /* Project object */;
45 | proxyType = 1;
46 | remoteGlobalIDString = 33CC111A2044C6BA0003C045;
47 | remoteInfo = FLX;
48 | };
49 | /* End PBXContainerItemProxy section */
50 |
51 | /* Begin PBXCopyFilesBuildPhase section */
52 | 33CC110E2044A8840003C045 /* Bundle Framework */ = {
53 | isa = PBXCopyFilesBuildPhase;
54 | buildActionMask = 2147483647;
55 | dstPath = "";
56 | dstSubfolderSpec = 10;
57 | files = (
58 | );
59 | name = "Bundle Framework";
60 | runOnlyForDeploymentPostprocessing = 0;
61 | };
62 | /* End PBXCopyFilesBuildPhase section */
63 |
64 | /* Begin PBXFileReference section */
65 | 083BECB9A01D8B89FE43B823 /* 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 = ""; };
66 | 331C80D5294CF71000263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
67 | 331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; };
68 | 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; };
69 | 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; };
70 | 33CC10ED2044A3C60003C045 /* calculator.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = calculator.app; sourceTree = BUILT_PRODUCTS_DIR; };
71 | 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
72 | 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; };
73 | 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; };
74 | 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; };
75 | 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; };
76 | 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; };
77 | 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; };
78 | 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; };
79 | 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; };
80 | 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; };
81 | 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; };
82 | 50B3FA88DEB827C5228F2522 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; };
83 | 5F47ECCE1B6185F3D2FEC06C /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
84 | 6D2012D051FC62D8B255CBF8 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
85 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; };
86 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; };
87 | 9BF36051311AD038EB75CD76 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = ""; };
88 | ADD262E9E4F361839262E437 /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; };
89 | E0B7179CEC0950043A5D3DBC /* 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 = ""; };
90 | EB975ED602F5F678AAC1040C /* 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 = ""; };
91 | /* End PBXFileReference section */
92 |
93 | /* Begin PBXFrameworksBuildPhase section */
94 | 331C80D2294CF70F00263BE5 /* Frameworks */ = {
95 | isa = PBXFrameworksBuildPhase;
96 | buildActionMask = 2147483647;
97 | files = (
98 | 234239F48EBE7A6FDBC2EE51 /* Pods_RunnerTests.framework in Frameworks */,
99 | );
100 | runOnlyForDeploymentPostprocessing = 0;
101 | };
102 | 33CC10EA2044A3C60003C045 /* Frameworks */ = {
103 | isa = PBXFrameworksBuildPhase;
104 | buildActionMask = 2147483647;
105 | files = (
106 | 8A436B48356ECC61603C7BAB /* Pods_Runner.framework in Frameworks */,
107 | );
108 | runOnlyForDeploymentPostprocessing = 0;
109 | };
110 | /* End PBXFrameworksBuildPhase section */
111 |
112 | /* Begin PBXGroup section */
113 | 331C80D6294CF71000263BE5 /* RunnerTests */ = {
114 | isa = PBXGroup;
115 | children = (
116 | 331C80D7294CF71000263BE5 /* RunnerTests.swift */,
117 | );
118 | path = RunnerTests;
119 | sourceTree = "";
120 | };
121 | 33BA886A226E78AF003329D5 /* Configs */ = {
122 | isa = PBXGroup;
123 | children = (
124 | 33E5194F232828860026EE4D /* AppInfo.xcconfig */,
125 | 9740EEB21CF90195004384FC /* Debug.xcconfig */,
126 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
127 | 333000ED22D3DE5D00554162 /* Warnings.xcconfig */,
128 | );
129 | path = Configs;
130 | sourceTree = "";
131 | };
132 | 33CC10E42044A3C60003C045 = {
133 | isa = PBXGroup;
134 | children = (
135 | 33FAB671232836740065AC1E /* Runner */,
136 | 33CEB47122A05771004F2AC0 /* Flutter */,
137 | 331C80D6294CF71000263BE5 /* RunnerTests */,
138 | 33CC10EE2044A3C60003C045 /* Products */,
139 | D73912EC22F37F3D000D13A0 /* Frameworks */,
140 | 3B5D131093AFCF76AF399F74 /* Pods */,
141 | );
142 | sourceTree = "";
143 | };
144 | 33CC10EE2044A3C60003C045 /* Products */ = {
145 | isa = PBXGroup;
146 | children = (
147 | 33CC10ED2044A3C60003C045 /* calculator.app */,
148 | 331C80D5294CF71000263BE5 /* RunnerTests.xctest */,
149 | );
150 | name = Products;
151 | sourceTree = "";
152 | };
153 | 33CC11242044D66E0003C045 /* Resources */ = {
154 | isa = PBXGroup;
155 | children = (
156 | 33CC10F22044A3C60003C045 /* Assets.xcassets */,
157 | 33CC10F42044A3C60003C045 /* MainMenu.xib */,
158 | 33CC10F72044A3C60003C045 /* Info.plist */,
159 | );
160 | name = Resources;
161 | path = ..;
162 | sourceTree = "";
163 | };
164 | 33CEB47122A05771004F2AC0 /* Flutter */ = {
165 | isa = PBXGroup;
166 | children = (
167 | 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */,
168 | 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */,
169 | 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */,
170 | 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */,
171 | );
172 | path = Flutter;
173 | sourceTree = "";
174 | };
175 | 33FAB671232836740065AC1E /* Runner */ = {
176 | isa = PBXGroup;
177 | children = (
178 | 33CC10F02044A3C60003C045 /* AppDelegate.swift */,
179 | 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */,
180 | 33E51913231747F40026EE4D /* DebugProfile.entitlements */,
181 | 33E51914231749380026EE4D /* Release.entitlements */,
182 | 33CC11242044D66E0003C045 /* Resources */,
183 | 33BA886A226E78AF003329D5 /* Configs */,
184 | );
185 | path = Runner;
186 | sourceTree = "";
187 | };
188 | 3B5D131093AFCF76AF399F74 /* Pods */ = {
189 | isa = PBXGroup;
190 | children = (
191 | EB975ED602F5F678AAC1040C /* Pods-Runner.debug.xcconfig */,
192 | E0B7179CEC0950043A5D3DBC /* Pods-Runner.release.xcconfig */,
193 | 083BECB9A01D8B89FE43B823 /* Pods-Runner.profile.xcconfig */,
194 | 50B3FA88DEB827C5228F2522 /* Pods-RunnerTests.debug.xcconfig */,
195 | ADD262E9E4F361839262E437 /* Pods-RunnerTests.release.xcconfig */,
196 | 9BF36051311AD038EB75CD76 /* Pods-RunnerTests.profile.xcconfig */,
197 | );
198 | name = Pods;
199 | path = Pods;
200 | sourceTree = "";
201 | };
202 | D73912EC22F37F3D000D13A0 /* Frameworks */ = {
203 | isa = PBXGroup;
204 | children = (
205 | 6D2012D051FC62D8B255CBF8 /* Pods_Runner.framework */,
206 | 5F47ECCE1B6185F3D2FEC06C /* Pods_RunnerTests.framework */,
207 | );
208 | name = Frameworks;
209 | sourceTree = "";
210 | };
211 | /* End PBXGroup section */
212 |
213 | /* Begin PBXNativeTarget section */
214 | 331C80D4294CF70F00263BE5 /* RunnerTests */ = {
215 | isa = PBXNativeTarget;
216 | buildConfigurationList = 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */;
217 | buildPhases = (
218 | 4F693EAC758568B522E5CEC8 /* [CP] Check Pods Manifest.lock */,
219 | 331C80D1294CF70F00263BE5 /* Sources */,
220 | 331C80D2294CF70F00263BE5 /* Frameworks */,
221 | 331C80D3294CF70F00263BE5 /* Resources */,
222 | );
223 | buildRules = (
224 | );
225 | dependencies = (
226 | 331C80DA294CF71000263BE5 /* PBXTargetDependency */,
227 | );
228 | name = RunnerTests;
229 | productName = RunnerTests;
230 | productReference = 331C80D5294CF71000263BE5 /* RunnerTests.xctest */;
231 | productType = "com.apple.product-type.bundle.unit-test";
232 | };
233 | 33CC10EC2044A3C60003C045 /* Runner */ = {
234 | isa = PBXNativeTarget;
235 | buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */;
236 | buildPhases = (
237 | C2B44EE66C95F4924EF512A8 /* [CP] Check Pods Manifest.lock */,
238 | 33CC10E92044A3C60003C045 /* Sources */,
239 | 33CC10EA2044A3C60003C045 /* Frameworks */,
240 | 33CC10EB2044A3C60003C045 /* Resources */,
241 | 33CC110E2044A8840003C045 /* Bundle Framework */,
242 | 3399D490228B24CF009A79C7 /* ShellScript */,
243 | BA028652B804319AAFE72166 /* [CP] Embed Pods Frameworks */,
244 | );
245 | buildRules = (
246 | );
247 | dependencies = (
248 | 33CC11202044C79F0003C045 /* PBXTargetDependency */,
249 | );
250 | name = Runner;
251 | productName = Runner;
252 | productReference = 33CC10ED2044A3C60003C045 /* calculator.app */;
253 | productType = "com.apple.product-type.application";
254 | };
255 | /* End PBXNativeTarget section */
256 |
257 | /* Begin PBXProject section */
258 | 33CC10E52044A3C60003C045 /* Project object */ = {
259 | isa = PBXProject;
260 | attributes = {
261 | LastSwiftUpdateCheck = 0920;
262 | LastUpgradeCheck = 1300;
263 | ORGANIZATIONNAME = "";
264 | TargetAttributes = {
265 | 331C80D4294CF70F00263BE5 = {
266 | CreatedOnToolsVersion = 14.0;
267 | TestTargetID = 33CC10EC2044A3C60003C045;
268 | };
269 | 33CC10EC2044A3C60003C045 = {
270 | CreatedOnToolsVersion = 9.2;
271 | LastSwiftMigration = 1100;
272 | ProvisioningStyle = Automatic;
273 | SystemCapabilities = {
274 | com.apple.Sandbox = {
275 | enabled = 1;
276 | };
277 | };
278 | };
279 | 33CC111A2044C6BA0003C045 = {
280 | CreatedOnToolsVersion = 9.2;
281 | ProvisioningStyle = Manual;
282 | };
283 | };
284 | };
285 | buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */;
286 | compatibilityVersion = "Xcode 9.3";
287 | developmentRegion = en;
288 | hasScannedForEncodings = 0;
289 | knownRegions = (
290 | en,
291 | Base,
292 | );
293 | mainGroup = 33CC10E42044A3C60003C045;
294 | productRefGroup = 33CC10EE2044A3C60003C045 /* Products */;
295 | projectDirPath = "";
296 | projectRoot = "";
297 | targets = (
298 | 33CC10EC2044A3C60003C045 /* Runner */,
299 | 331C80D4294CF70F00263BE5 /* RunnerTests */,
300 | 33CC111A2044C6BA0003C045 /* Flutter Assemble */,
301 | );
302 | };
303 | /* End PBXProject section */
304 |
305 | /* Begin PBXResourcesBuildPhase section */
306 | 331C80D3294CF70F00263BE5 /* Resources */ = {
307 | isa = PBXResourcesBuildPhase;
308 | buildActionMask = 2147483647;
309 | files = (
310 | );
311 | runOnlyForDeploymentPostprocessing = 0;
312 | };
313 | 33CC10EB2044A3C60003C045 /* Resources */ = {
314 | isa = PBXResourcesBuildPhase;
315 | buildActionMask = 2147483647;
316 | files = (
317 | 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */,
318 | 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */,
319 | );
320 | runOnlyForDeploymentPostprocessing = 0;
321 | };
322 | /* End PBXResourcesBuildPhase section */
323 |
324 | /* Begin PBXShellScriptBuildPhase section */
325 | 3399D490228B24CF009A79C7 /* ShellScript */ = {
326 | isa = PBXShellScriptBuildPhase;
327 | alwaysOutOfDate = 1;
328 | buildActionMask = 2147483647;
329 | files = (
330 | );
331 | inputFileListPaths = (
332 | );
333 | inputPaths = (
334 | );
335 | outputFileListPaths = (
336 | );
337 | outputPaths = (
338 | );
339 | runOnlyForDeploymentPostprocessing = 0;
340 | shellPath = /bin/sh;
341 | shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n";
342 | };
343 | 33CC111E2044C6BF0003C045 /* ShellScript */ = {
344 | isa = PBXShellScriptBuildPhase;
345 | buildActionMask = 2147483647;
346 | files = (
347 | );
348 | inputFileListPaths = (
349 | Flutter/ephemeral/FlutterInputs.xcfilelist,
350 | );
351 | inputPaths = (
352 | Flutter/ephemeral/tripwire,
353 | );
354 | outputFileListPaths = (
355 | Flutter/ephemeral/FlutterOutputs.xcfilelist,
356 | );
357 | outputPaths = (
358 | );
359 | runOnlyForDeploymentPostprocessing = 0;
360 | shellPath = /bin/sh;
361 | shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire";
362 | };
363 | 4F693EAC758568B522E5CEC8 /* [CP] Check Pods Manifest.lock */ = {
364 | isa = PBXShellScriptBuildPhase;
365 | buildActionMask = 2147483647;
366 | files = (
367 | );
368 | inputFileListPaths = (
369 | );
370 | inputPaths = (
371 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
372 | "${PODS_ROOT}/Manifest.lock",
373 | );
374 | name = "[CP] Check Pods Manifest.lock";
375 | outputFileListPaths = (
376 | );
377 | outputPaths = (
378 | "$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt",
379 | );
380 | runOnlyForDeploymentPostprocessing = 0;
381 | shellPath = /bin/sh;
382 | 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";
383 | showEnvVarsInLog = 0;
384 | };
385 | BA028652B804319AAFE72166 /* [CP] Embed Pods Frameworks */ = {
386 | isa = PBXShellScriptBuildPhase;
387 | buildActionMask = 2147483647;
388 | files = (
389 | );
390 | inputFileListPaths = (
391 | "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
392 | );
393 | name = "[CP] Embed Pods Frameworks";
394 | outputFileListPaths = (
395 | "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
396 | );
397 | runOnlyForDeploymentPostprocessing = 0;
398 | shellPath = /bin/sh;
399 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
400 | showEnvVarsInLog = 0;
401 | };
402 | C2B44EE66C95F4924EF512A8 /* [CP] Check Pods Manifest.lock */ = {
403 | isa = PBXShellScriptBuildPhase;
404 | buildActionMask = 2147483647;
405 | files = (
406 | );
407 | inputFileListPaths = (
408 | );
409 | inputPaths = (
410 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
411 | "${PODS_ROOT}/Manifest.lock",
412 | );
413 | name = "[CP] Check Pods Manifest.lock";
414 | outputFileListPaths = (
415 | );
416 | outputPaths = (
417 | "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
418 | );
419 | runOnlyForDeploymentPostprocessing = 0;
420 | shellPath = /bin/sh;
421 | 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";
422 | showEnvVarsInLog = 0;
423 | };
424 | /* End PBXShellScriptBuildPhase section */
425 |
426 | /* Begin PBXSourcesBuildPhase section */
427 | 331C80D1294CF70F00263BE5 /* Sources */ = {
428 | isa = PBXSourcesBuildPhase;
429 | buildActionMask = 2147483647;
430 | files = (
431 | 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */,
432 | );
433 | runOnlyForDeploymentPostprocessing = 0;
434 | };
435 | 33CC10E92044A3C60003C045 /* Sources */ = {
436 | isa = PBXSourcesBuildPhase;
437 | buildActionMask = 2147483647;
438 | files = (
439 | 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */,
440 | 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */,
441 | 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */,
442 | );
443 | runOnlyForDeploymentPostprocessing = 0;
444 | };
445 | /* End PBXSourcesBuildPhase section */
446 |
447 | /* Begin PBXTargetDependency section */
448 | 331C80DA294CF71000263BE5 /* PBXTargetDependency */ = {
449 | isa = PBXTargetDependency;
450 | target = 33CC10EC2044A3C60003C045 /* Runner */;
451 | targetProxy = 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */;
452 | };
453 | 33CC11202044C79F0003C045 /* PBXTargetDependency */ = {
454 | isa = PBXTargetDependency;
455 | target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */;
456 | targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */;
457 | };
458 | /* End PBXTargetDependency section */
459 |
460 | /* Begin PBXVariantGroup section */
461 | 33CC10F42044A3C60003C045 /* MainMenu.xib */ = {
462 | isa = PBXVariantGroup;
463 | children = (
464 | 33CC10F52044A3C60003C045 /* Base */,
465 | );
466 | name = MainMenu.xib;
467 | path = Runner;
468 | sourceTree = "";
469 | };
470 | /* End PBXVariantGroup section */
471 |
472 | /* Begin XCBuildConfiguration section */
473 | 331C80DB294CF71000263BE5 /* Debug */ = {
474 | isa = XCBuildConfiguration;
475 | baseConfigurationReference = 50B3FA88DEB827C5228F2522 /* Pods-RunnerTests.debug.xcconfig */;
476 | buildSettings = {
477 | BUNDLE_LOADER = "$(TEST_HOST)";
478 | CURRENT_PROJECT_VERSION = 1;
479 | GENERATE_INFOPLIST_FILE = YES;
480 | MARKETING_VERSION = 1.0;
481 | PRODUCT_BUNDLE_IDENTIFIER = com.example.calculator.RunnerTests;
482 | PRODUCT_NAME = "$(TARGET_NAME)";
483 | SWIFT_VERSION = 5.0;
484 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/calculator.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/calculator";
485 | };
486 | name = Debug;
487 | };
488 | 331C80DC294CF71000263BE5 /* Release */ = {
489 | isa = XCBuildConfiguration;
490 | baseConfigurationReference = ADD262E9E4F361839262E437 /* Pods-RunnerTests.release.xcconfig */;
491 | buildSettings = {
492 | BUNDLE_LOADER = "$(TEST_HOST)";
493 | CURRENT_PROJECT_VERSION = 1;
494 | GENERATE_INFOPLIST_FILE = YES;
495 | MARKETING_VERSION = 1.0;
496 | PRODUCT_BUNDLE_IDENTIFIER = com.example.calculator.RunnerTests;
497 | PRODUCT_NAME = "$(TARGET_NAME)";
498 | SWIFT_VERSION = 5.0;
499 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/calculator.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/calculator";
500 | };
501 | name = Release;
502 | };
503 | 331C80DD294CF71000263BE5 /* Profile */ = {
504 | isa = XCBuildConfiguration;
505 | baseConfigurationReference = 9BF36051311AD038EB75CD76 /* Pods-RunnerTests.profile.xcconfig */;
506 | buildSettings = {
507 | BUNDLE_LOADER = "$(TEST_HOST)";
508 | CURRENT_PROJECT_VERSION = 1;
509 | GENERATE_INFOPLIST_FILE = YES;
510 | MARKETING_VERSION = 1.0;
511 | PRODUCT_BUNDLE_IDENTIFIER = com.example.calculator.RunnerTests;
512 | PRODUCT_NAME = "$(TARGET_NAME)";
513 | SWIFT_VERSION = 5.0;
514 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/calculator.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/calculator";
515 | };
516 | name = Profile;
517 | };
518 | 338D0CE9231458BD00FA5F75 /* Profile */ = {
519 | isa = XCBuildConfiguration;
520 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
521 | buildSettings = {
522 | ALWAYS_SEARCH_USER_PATHS = NO;
523 | CLANG_ANALYZER_NONNULL = YES;
524 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
525 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
526 | CLANG_CXX_LIBRARY = "libc++";
527 | CLANG_ENABLE_MODULES = YES;
528 | CLANG_ENABLE_OBJC_ARC = YES;
529 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
530 | CLANG_WARN_BOOL_CONVERSION = YES;
531 | CLANG_WARN_CONSTANT_CONVERSION = YES;
532 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
533 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
534 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
535 | CLANG_WARN_EMPTY_BODY = YES;
536 | CLANG_WARN_ENUM_CONVERSION = YES;
537 | CLANG_WARN_INFINITE_RECURSION = YES;
538 | CLANG_WARN_INT_CONVERSION = YES;
539 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
540 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
541 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
542 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
543 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
544 | CODE_SIGN_IDENTITY = "-";
545 | COPY_PHASE_STRIP = NO;
546 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
547 | ENABLE_NS_ASSERTIONS = NO;
548 | ENABLE_STRICT_OBJC_MSGSEND = YES;
549 | GCC_C_LANGUAGE_STANDARD = gnu11;
550 | GCC_NO_COMMON_BLOCKS = YES;
551 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
552 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
553 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
554 | GCC_WARN_UNUSED_FUNCTION = YES;
555 | GCC_WARN_UNUSED_VARIABLE = YES;
556 | MACOSX_DEPLOYMENT_TARGET = 10.14;
557 | MTL_ENABLE_DEBUG_INFO = NO;
558 | SDKROOT = macosx;
559 | SWIFT_COMPILATION_MODE = wholemodule;
560 | SWIFT_OPTIMIZATION_LEVEL = "-O";
561 | };
562 | name = Profile;
563 | };
564 | 338D0CEA231458BD00FA5F75 /* Profile */ = {
565 | isa = XCBuildConfiguration;
566 | baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */;
567 | buildSettings = {
568 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
569 | CLANG_ENABLE_MODULES = YES;
570 | CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
571 | CODE_SIGN_STYLE = Automatic;
572 | COMBINE_HIDPI_IMAGES = YES;
573 | INFOPLIST_FILE = Runner/Info.plist;
574 | LD_RUNPATH_SEARCH_PATHS = (
575 | "$(inherited)",
576 | "@executable_path/../Frameworks",
577 | );
578 | PROVISIONING_PROFILE_SPECIFIER = "";
579 | SWIFT_VERSION = 5.0;
580 | };
581 | name = Profile;
582 | };
583 | 338D0CEB231458BD00FA5F75 /* Profile */ = {
584 | isa = XCBuildConfiguration;
585 | buildSettings = {
586 | CODE_SIGN_STYLE = Manual;
587 | PRODUCT_NAME = "$(TARGET_NAME)";
588 | };
589 | name = Profile;
590 | };
591 | 33CC10F92044A3C60003C045 /* Debug */ = {
592 | isa = XCBuildConfiguration;
593 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
594 | buildSettings = {
595 | ALWAYS_SEARCH_USER_PATHS = NO;
596 | CLANG_ANALYZER_NONNULL = YES;
597 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
598 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
599 | CLANG_CXX_LIBRARY = "libc++";
600 | CLANG_ENABLE_MODULES = YES;
601 | CLANG_ENABLE_OBJC_ARC = YES;
602 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
603 | CLANG_WARN_BOOL_CONVERSION = YES;
604 | CLANG_WARN_CONSTANT_CONVERSION = YES;
605 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
606 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
607 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
608 | CLANG_WARN_EMPTY_BODY = YES;
609 | CLANG_WARN_ENUM_CONVERSION = YES;
610 | CLANG_WARN_INFINITE_RECURSION = YES;
611 | CLANG_WARN_INT_CONVERSION = YES;
612 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
613 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
614 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
615 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
616 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
617 | CODE_SIGN_IDENTITY = "-";
618 | COPY_PHASE_STRIP = NO;
619 | DEBUG_INFORMATION_FORMAT = dwarf;
620 | ENABLE_STRICT_OBJC_MSGSEND = YES;
621 | ENABLE_TESTABILITY = YES;
622 | GCC_C_LANGUAGE_STANDARD = gnu11;
623 | GCC_DYNAMIC_NO_PIC = NO;
624 | GCC_NO_COMMON_BLOCKS = YES;
625 | GCC_OPTIMIZATION_LEVEL = 0;
626 | GCC_PREPROCESSOR_DEFINITIONS = (
627 | "DEBUG=1",
628 | "$(inherited)",
629 | );
630 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
631 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
632 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
633 | GCC_WARN_UNUSED_FUNCTION = YES;
634 | GCC_WARN_UNUSED_VARIABLE = YES;
635 | MACOSX_DEPLOYMENT_TARGET = 10.14;
636 | MTL_ENABLE_DEBUG_INFO = YES;
637 | ONLY_ACTIVE_ARCH = YES;
638 | SDKROOT = macosx;
639 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
640 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
641 | };
642 | name = Debug;
643 | };
644 | 33CC10FA2044A3C60003C045 /* Release */ = {
645 | isa = XCBuildConfiguration;
646 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
647 | buildSettings = {
648 | ALWAYS_SEARCH_USER_PATHS = NO;
649 | CLANG_ANALYZER_NONNULL = YES;
650 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
651 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
652 | CLANG_CXX_LIBRARY = "libc++";
653 | CLANG_ENABLE_MODULES = YES;
654 | CLANG_ENABLE_OBJC_ARC = YES;
655 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
656 | CLANG_WARN_BOOL_CONVERSION = YES;
657 | CLANG_WARN_CONSTANT_CONVERSION = YES;
658 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
659 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
660 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
661 | CLANG_WARN_EMPTY_BODY = YES;
662 | CLANG_WARN_ENUM_CONVERSION = YES;
663 | CLANG_WARN_INFINITE_RECURSION = YES;
664 | CLANG_WARN_INT_CONVERSION = YES;
665 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
666 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
667 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
668 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
669 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
670 | CODE_SIGN_IDENTITY = "-";
671 | COPY_PHASE_STRIP = NO;
672 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
673 | ENABLE_NS_ASSERTIONS = NO;
674 | ENABLE_STRICT_OBJC_MSGSEND = YES;
675 | GCC_C_LANGUAGE_STANDARD = gnu11;
676 | GCC_NO_COMMON_BLOCKS = YES;
677 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
678 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
679 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
680 | GCC_WARN_UNUSED_FUNCTION = YES;
681 | GCC_WARN_UNUSED_VARIABLE = YES;
682 | MACOSX_DEPLOYMENT_TARGET = 10.14;
683 | MTL_ENABLE_DEBUG_INFO = NO;
684 | SDKROOT = macosx;
685 | SWIFT_COMPILATION_MODE = wholemodule;
686 | SWIFT_OPTIMIZATION_LEVEL = "-O";
687 | };
688 | name = Release;
689 | };
690 | 33CC10FC2044A3C60003C045 /* Debug */ = {
691 | isa = XCBuildConfiguration;
692 | baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */;
693 | buildSettings = {
694 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
695 | CLANG_ENABLE_MODULES = YES;
696 | CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
697 | CODE_SIGN_STYLE = Automatic;
698 | COMBINE_HIDPI_IMAGES = YES;
699 | INFOPLIST_FILE = Runner/Info.plist;
700 | LD_RUNPATH_SEARCH_PATHS = (
701 | "$(inherited)",
702 | "@executable_path/../Frameworks",
703 | );
704 | PROVISIONING_PROFILE_SPECIFIER = "";
705 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
706 | SWIFT_VERSION = 5.0;
707 | };
708 | name = Debug;
709 | };
710 | 33CC10FD2044A3C60003C045 /* Release */ = {
711 | isa = XCBuildConfiguration;
712 | baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */;
713 | buildSettings = {
714 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
715 | CLANG_ENABLE_MODULES = YES;
716 | CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements;
717 | CODE_SIGN_STYLE = Automatic;
718 | COMBINE_HIDPI_IMAGES = YES;
719 | INFOPLIST_FILE = Runner/Info.plist;
720 | LD_RUNPATH_SEARCH_PATHS = (
721 | "$(inherited)",
722 | "@executable_path/../Frameworks",
723 | );
724 | PROVISIONING_PROFILE_SPECIFIER = "";
725 | SWIFT_VERSION = 5.0;
726 | };
727 | name = Release;
728 | };
729 | 33CC111C2044C6BA0003C045 /* Debug */ = {
730 | isa = XCBuildConfiguration;
731 | buildSettings = {
732 | CODE_SIGN_STYLE = Manual;
733 | PRODUCT_NAME = "$(TARGET_NAME)";
734 | };
735 | name = Debug;
736 | };
737 | 33CC111D2044C6BA0003C045 /* Release */ = {
738 | isa = XCBuildConfiguration;
739 | buildSettings = {
740 | CODE_SIGN_STYLE = Automatic;
741 | PRODUCT_NAME = "$(TARGET_NAME)";
742 | };
743 | name = Release;
744 | };
745 | /* End XCBuildConfiguration section */
746 |
747 | /* Begin XCConfigurationList section */
748 | 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = {
749 | isa = XCConfigurationList;
750 | buildConfigurations = (
751 | 331C80DB294CF71000263BE5 /* Debug */,
752 | 331C80DC294CF71000263BE5 /* Release */,
753 | 331C80DD294CF71000263BE5 /* Profile */,
754 | );
755 | defaultConfigurationIsVisible = 0;
756 | defaultConfigurationName = Release;
757 | };
758 | 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = {
759 | isa = XCConfigurationList;
760 | buildConfigurations = (
761 | 33CC10F92044A3C60003C045 /* Debug */,
762 | 33CC10FA2044A3C60003C045 /* Release */,
763 | 338D0CE9231458BD00FA5F75 /* Profile */,
764 | );
765 | defaultConfigurationIsVisible = 0;
766 | defaultConfigurationName = Release;
767 | };
768 | 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = {
769 | isa = XCConfigurationList;
770 | buildConfigurations = (
771 | 33CC10FC2044A3C60003C045 /* Debug */,
772 | 33CC10FD2044A3C60003C045 /* Release */,
773 | 338D0CEA231458BD00FA5F75 /* Profile */,
774 | );
775 | defaultConfigurationIsVisible = 0;
776 | defaultConfigurationName = Release;
777 | };
778 | 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = {
779 | isa = XCConfigurationList;
780 | buildConfigurations = (
781 | 33CC111C2044C6BA0003C045 /* Debug */,
782 | 33CC111D2044C6BA0003C045 /* Release */,
783 | 338D0CEB231458BD00FA5F75 /* Profile */,
784 | );
785 | defaultConfigurationIsVisible = 0;
786 | defaultConfigurationName = Release;
787 | };
788 | /* End XCConfigurationList section */
789 | };
790 | rootObject = 33CC10E52044A3C60003C045 /* Project object */;
791 | }
792 |
--------------------------------------------------------------------------------
/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
37 |
38 |
39 |
40 |
43 |
49 |
50 |
51 |
52 |
53 |
63 |
65 |
71 |
72 |
73 |
74 |
80 |
82 |
88 |
89 |
90 |
91 |
93 |
94 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/macos/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubuntu-flutter-community/calculator/4c0dbbced2b36c2471f41369f79981979a5cd436/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubuntu-flutter-community/calculator/4c0dbbced2b36c2471f41369f79981979a5cd436/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubuntu-flutter-community/calculator/4c0dbbced2b36c2471f41369f79981979a5cd436/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubuntu-flutter-community/calculator/4c0dbbced2b36c2471f41369f79981979a5cd436/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubuntu-flutter-community/calculator/4c0dbbced2b36c2471f41369f79981979a5cd436/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubuntu-flutter-community/calculator/4c0dbbced2b36c2471f41369f79981979a5cd436/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubuntu-flutter-community/calculator/4c0dbbced2b36c2471f41369f79981979a5cd436/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png
--------------------------------------------------------------------------------
/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 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
--------------------------------------------------------------------------------
/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 = calculator
9 |
10 | // The application's bundle identifier
11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.calculator
12 |
13 | // The copyright displayed in application information
14 | PRODUCT_COPYRIGHT = Copyright © 2023 com.example. All rights reserved.
15 |
--------------------------------------------------------------------------------
/macos/Runner/Configs/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "../../Flutter/Flutter-Debug.xcconfig"
2 | #include "Warnings.xcconfig"
3 |
--------------------------------------------------------------------------------
/macos/Runner/Configs/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "../../Flutter/Flutter-Release.xcconfig"
2 | #include "Warnings.xcconfig"
3 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/macos/Runner/MainFlutterWindow.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 | import FlutterMacOS
3 |
4 | class MainFlutterWindow: NSWindow {
5 | override func awakeFromNib() {
6 | let flutterViewController = FlutterViewController()
7 | let origin = self.frame.origin
8 | self.contentViewController = flutterViewController
9 | self.setFrame(CGRect(x: origin.x, y: origin.y, width: 360, height: 480), display: true)
10 |
11 | RegisterGeneratedPlugins(registry: flutterViewController)
12 |
13 | super.awakeFromNib()
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/macos/Runner/Release.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.app-sandbox
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/macos/RunnerTests/RunnerTests.swift:
--------------------------------------------------------------------------------
1 | import FlutterMacOS
2 | import Cocoa
3 | import XCTest
4 |
5 | class RunnerTests: XCTestCase {
6 |
7 | func testExample() {
8 | // If you add code to the Runner application, consider adding tests here.
9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest.
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: calculator
2 | description: Calculator example
3 | publish_to: 'none'
4 |
5 | environment:
6 | sdk: '>=3.0.0 <4.0.0'
7 | flutter: '>=3.10.0'
8 |
9 | dependencies:
10 | collection: ^1.16.0
11 | flutter:
12 | sdk: flutter
13 | flutter_localizations:
14 | sdk: flutter
15 | handy_window: ^0.3.0
16 | intl: ^0.18.0
17 | math_expressions: ^2.4.0
18 | meta: ^1.8.0
19 | provider: ^6.0.5
20 | yaru: ^0.5.0
21 | yaru_icons: ^1.0.1
22 | yaru_widgets: ^2.1.0
23 |
24 | dev_dependencies:
25 | flutter_lints: ^2.0.0
26 | flutter_test:
27 | sdk: flutter
28 |
29 | flutter:
30 | generate: true
31 | uses-material-design: true
32 | assets:
33 | - assets/
34 |
--------------------------------------------------------------------------------
/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubuntu-flutter-community/calculator/4c0dbbced2b36c2471f41369f79981979a5cd436/screenshot.png
--------------------------------------------------------------------------------
/snap/snapcraft.yaml:
--------------------------------------------------------------------------------
1 | name: calculator
2 | version: git
3 | summary: Calculator
4 | description: Calculator example
5 | confinement: strict
6 | base: core22
7 | grade: stable
8 | license: GPL-3.0+
9 | architectures:
10 | - build-on: amd64
11 | build-for: amd64
12 | - build-on: arm64
13 | build-for: arm64
14 |
15 | parts:
16 | calculator:
17 | plugin: flutter
18 | source: .
19 |
20 | apps:
21 | calculator:
22 | command: calculator
23 | desktop: data/flutter_assets/assets/calculator.desktop
24 | extensions: [gnome]
25 |
--------------------------------------------------------------------------------
/test/calculator_test.dart:
--------------------------------------------------------------------------------
1 | import 'package:calculator/calculator.dart';
2 | import 'package:flutter_test/flutter_test.dart';
3 |
4 | void main() {
5 | test('calculate', () {
6 | final calculator = Calculator();
7 | expect(calculator.history, isEmpty);
8 |
9 | var wasNotified = 0;
10 | var expectedNotified = 0;
11 | calculator.addListener(() => ++wasNotified);
12 |
13 | expect(calculator.calculate('1+2'), 3);
14 | expect(calculator.history, hasLength(1));
15 | expect(calculator.history.single, isCalculation(input: '1+2', result: 3));
16 | expect(wasNotified, ++expectedNotified);
17 |
18 | expect(calculator.calculate('x = 4 * 5'), 20);
19 | expect(calculator.history, hasLength(2));
20 | expect(calculator.history.first, isCalculation(input: '1+2', result: 3));
21 | expect(calculator.history.last,
22 | isCalculation(input: 'x = 4 * 5', variable: 'x', result: 20));
23 | expect(wasNotified, ++expectedNotified);
24 |
25 | calculator.clear();
26 | expect(calculator.history, isEmpty);
27 | expect(wasNotified, ++expectedNotified);
28 | });
29 | }
30 |
31 | Matcher isCalculation({
32 | required String input,
33 | String? variable,
34 | required dynamic result,
35 | }) {
36 | return isA()
37 | .having((c) => c.input, 'input', input)
38 | .having((c) => c.variable, 'variable', variable)
39 | .having((c) => c.result, 'result', result);
40 | }
41 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/windows/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Project-level configuration.
2 | cmake_minimum_required(VERSION 3.14)
3 | project(calculator LANGUAGES CXX)
4 |
5 | # The name of the executable created for the application. Change this to change
6 | # the on-disk name of your application.
7 | set(BINARY_NAME "calculator")
8 |
9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent
10 | # versions of CMake.
11 | cmake_policy(SET CMP0063 NEW)
12 |
13 | # Define build configuration option.
14 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
15 | if(IS_MULTICONFIG)
16 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release"
17 | CACHE STRING "" FORCE)
18 | else()
19 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
20 | set(CMAKE_BUILD_TYPE "Debug" CACHE
21 | STRING "Flutter build mode" FORCE)
22 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
23 | "Debug" "Profile" "Release")
24 | endif()
25 | endif()
26 | # Define settings for the Profile build mode.
27 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
28 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
29 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}")
30 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}")
31 |
32 | # Use Unicode for all projects.
33 | add_definitions(-DUNICODE -D_UNICODE)
34 |
35 | # Compilation settings that should be applied to most targets.
36 | #
37 | # Be cautious about adding new options here, as plugins use this function by
38 | # default. In most cases, you should add new options to specific targets instead
39 | # of modifying this function.
40 | function(APPLY_STANDARD_SETTINGS TARGET)
41 | target_compile_features(${TARGET} PUBLIC cxx_std_17)
42 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
43 | target_compile_options(${TARGET} PRIVATE /EHsc)
44 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
45 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>")
46 | endfunction()
47 |
48 | # Flutter library and tool build rules.
49 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
50 | add_subdirectory(${FLUTTER_MANAGED_DIR})
51 |
52 | # Application build; see runner/CMakeLists.txt.
53 | add_subdirectory("runner")
54 |
55 |
56 | # Generated plugin build rules, which manage building the plugins and adding
57 | # them to the application.
58 | include(flutter/generated_plugins.cmake)
59 |
60 |
61 | # === Installation ===
62 | # Support files are copied into place next to the executable, so that it can
63 | # run in place. This is done instead of making a separate bundle (as on Linux)
64 | # so that building and running from within Visual Studio will work.
65 | set(BUILD_BUNDLE_DIR "$")
66 | # Make the "install" step default, as it's required to run.
67 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
68 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
69 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
70 | endif()
71 |
72 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
73 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}")
74 |
75 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
76 | COMPONENT Runtime)
77 |
78 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
79 | COMPONENT Runtime)
80 |
81 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
82 | COMPONENT Runtime)
83 |
84 | if(PLUGIN_BUNDLED_LIBRARIES)
85 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
86 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
87 | COMPONENT Runtime)
88 | endif()
89 |
90 | # Fully re-copy the assets directory on each build to avoid having stale files
91 | # from a previous install.
92 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
93 | install(CODE "
94 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
95 | " COMPONENT Runtime)
96 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
97 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
98 |
99 | # Install the AOT library on non-Debug builds only.
100 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
101 | CONFIGURATIONS Profile;Release
102 | COMPONENT Runtime)
103 |
--------------------------------------------------------------------------------
/windows/flutter/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # This file controls Flutter-level build steps. It should not be edited.
2 | cmake_minimum_required(VERSION 3.14)
3 |
4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
5 |
6 | # Configuration provided via flutter tool.
7 | include(${EPHEMERAL_DIR}/generated_config.cmake)
8 |
9 | # TODO: Move the rest of this into files in ephemeral. See
10 | # https://github.com/flutter/flutter/issues/57146.
11 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")
12 |
13 | # === Flutter Library ===
14 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")
15 |
16 | # Published to parent scope for install step.
17 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
18 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
19 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
20 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE)
21 |
22 | list(APPEND FLUTTER_LIBRARY_HEADERS
23 | "flutter_export.h"
24 | "flutter_windows.h"
25 | "flutter_messenger.h"
26 | "flutter_plugin_registrar.h"
27 | "flutter_texture_registrar.h"
28 | )
29 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/")
30 | add_library(flutter INTERFACE)
31 | target_include_directories(flutter INTERFACE
32 | "${EPHEMERAL_DIR}"
33 | )
34 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib")
35 | add_dependencies(flutter flutter_assemble)
36 |
37 | # === Wrapper ===
38 | list(APPEND CPP_WRAPPER_SOURCES_CORE
39 | "core_implementations.cc"
40 | "standard_codec.cc"
41 | )
42 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/")
43 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN
44 | "plugin_registrar.cc"
45 | )
46 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/")
47 | list(APPEND CPP_WRAPPER_SOURCES_APP
48 | "flutter_engine.cc"
49 | "flutter_view_controller.cc"
50 | )
51 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/")
52 |
53 | # Wrapper sources needed for a plugin.
54 | add_library(flutter_wrapper_plugin STATIC
55 | ${CPP_WRAPPER_SOURCES_CORE}
56 | ${CPP_WRAPPER_SOURCES_PLUGIN}
57 | )
58 | apply_standard_settings(flutter_wrapper_plugin)
59 | set_target_properties(flutter_wrapper_plugin PROPERTIES
60 | POSITION_INDEPENDENT_CODE ON)
61 | set_target_properties(flutter_wrapper_plugin PROPERTIES
62 | CXX_VISIBILITY_PRESET hidden)
63 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter)
64 | target_include_directories(flutter_wrapper_plugin PUBLIC
65 | "${WRAPPER_ROOT}/include"
66 | )
67 | add_dependencies(flutter_wrapper_plugin flutter_assemble)
68 |
69 | # Wrapper sources needed for the runner.
70 | add_library(flutter_wrapper_app STATIC
71 | ${CPP_WRAPPER_SOURCES_CORE}
72 | ${CPP_WRAPPER_SOURCES_APP}
73 | )
74 | apply_standard_settings(flutter_wrapper_app)
75 | target_link_libraries(flutter_wrapper_app PUBLIC flutter)
76 | target_include_directories(flutter_wrapper_app PUBLIC
77 | "${WRAPPER_ROOT}/include"
78 | )
79 | add_dependencies(flutter_wrapper_app flutter_assemble)
80 |
81 | # === Flutter tool backend ===
82 | # _phony_ is a non-existent file to force this command to run every time,
83 | # since currently there's no way to get a full input/output list from the
84 | # flutter tool.
85 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_")
86 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE)
87 | add_custom_command(
88 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
89 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN}
90 | ${CPP_WRAPPER_SOURCES_APP}
91 | ${PHONY_OUTPUT}
92 | COMMAND ${CMAKE_COMMAND} -E env
93 | ${FLUTTER_TOOL_ENVIRONMENT}
94 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
95 | windows-x64 $
96 | VERBATIM
97 | )
98 | add_custom_target(flutter_assemble DEPENDS
99 | "${FLUTTER_LIBRARY}"
100 | ${FLUTTER_LIBRARY_HEADERS}
101 | ${CPP_WRAPPER_SOURCES_CORE}
102 | ${CPP_WRAPPER_SOURCES_PLUGIN}
103 | ${CPP_WRAPPER_SOURCES_APP}
104 | )
105 |
--------------------------------------------------------------------------------
/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 |
12 | void RegisterPlugins(flutter::PluginRegistry* registry) {
13 | ScreenRetrieverPluginRegisterWithRegistrar(
14 | registry->GetRegistrarForPlugin("ScreenRetrieverPlugin"));
15 | WindowManagerPluginRegisterWithRegistrar(
16 | registry->GetRegistrarForPlugin("WindowManagerPlugin"));
17 | }
18 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/windows/flutter/generated_plugins.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Generated file, do not edit.
3 | #
4 |
5 | list(APPEND FLUTTER_PLUGIN_LIST
6 | screen_retriever
7 | window_manager
8 | )
9 |
10 | list(APPEND FLUTTER_FFI_PLUGIN_LIST
11 | )
12 |
13 | set(PLUGIN_BUNDLED_LIBRARIES)
14 |
15 | foreach(plugin ${FLUTTER_PLUGIN_LIST})
16 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin})
17 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $)
19 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
20 | endforeach(plugin)
21 |
22 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
23 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
24 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
25 | endforeach(ffi_plugin)
26 |
--------------------------------------------------------------------------------
/windows/runner/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.14)
2 | project(runner LANGUAGES CXX)
3 |
4 | # Define the application target. To change its name, change BINARY_NAME in the
5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer
6 | # work.
7 | #
8 | # Any new source files that you add to the application should be added here.
9 | add_executable(${BINARY_NAME} WIN32
10 | "flutter_window.cpp"
11 | "main.cpp"
12 | "utils.cpp"
13 | "win32_window.cpp"
14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
15 | "Runner.rc"
16 | "runner.exe.manifest"
17 | )
18 |
19 | # Apply the standard set of build settings. This can be removed for applications
20 | # that need different build settings.
21 | apply_standard_settings(${BINARY_NAME})
22 |
23 | # Add preprocessor definitions for the build version.
24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"")
25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}")
26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}")
27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}")
28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}")
29 |
30 | # Disable Windows macros that collide with C++ standard library functions.
31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
32 |
33 | # Add dependency libraries and include directories. Add any application-specific
34 | # dependencies here.
35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
36 | target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib")
37 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
38 |
39 | # Run the Flutter tool portions of the build. This must not be removed.
40 | add_dependencies(${BINARY_NAME} flutter_assemble)
41 |
--------------------------------------------------------------------------------
/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 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD)
64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD
65 | #else
66 | #define VERSION_AS_NUMBER 1,0,0,0
67 | #endif
68 |
69 | #if defined(FLUTTER_VERSION)
70 | #define VERSION_AS_STRING FLUTTER_VERSION
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", "calculator" "\0"
94 | VALUE "FileVersion", VERSION_AS_STRING "\0"
95 | VALUE "InternalName", "calculator" "\0"
96 | VALUE "LegalCopyright", "Copyright (C) 2023 com.example. All rights reserved." "\0"
97 | VALUE "OriginalFilename", "calculator.exe" "\0"
98 | VALUE "ProductName", "calculator" "\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 |
--------------------------------------------------------------------------------
/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(const flutter::DartProject& project)
8 | : project_(project) {}
9 |
10 | FlutterWindow::~FlutterWindow() {}
11 |
12 | bool FlutterWindow::OnCreate() {
13 | if (!Win32Window::OnCreate()) {
14 | return false;
15 | }
16 |
17 | RECT frame = GetClientArea();
18 |
19 | // The size here must match the window dimensions to avoid unnecessary surface
20 | // creation / destruction in the startup path.
21 | flutter_controller_ = std::make_unique(
22 | frame.right - frame.left, frame.bottom - frame.top, project_);
23 | // Ensure that basic setup of the controller was successful.
24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) {
25 | return false;
26 | }
27 | RegisterPlugins(flutter_controller_->engine());
28 | SetChildContent(flutter_controller_->view()->GetNativeWindow());
29 |
30 | flutter_controller_->engine()->SetNextFrameCallback([&]() {
31 | this->Show();
32 | });
33 |
34 | return true;
35 | }
36 |
37 | void FlutterWindow::OnDestroy() {
38 | if (flutter_controller_) {
39 | flutter_controller_ = nullptr;
40 | }
41 |
42 | Win32Window::OnDestroy();
43 | }
44 |
45 | LRESULT
46 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message,
47 | WPARAM const wparam,
48 | LPARAM const lparam) noexcept {
49 | // Give Flutter, including plugins, an opportunity to handle window messages.
50 | if (flutter_controller_) {
51 | std::optional result =
52 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam,
53 | lparam);
54 | if (result) {
55 | return *result;
56 | }
57 | }
58 |
59 | switch (message) {
60 | case WM_FONTCHANGE:
61 | flutter_controller_->engine()->ReloadSystemFonts();
62 | break;
63 | }
64 |
65 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam);
66 | }
67 |
--------------------------------------------------------------------------------
/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 "win32_window.h"
10 |
11 | // A window that does nothing but host a Flutter view.
12 | class FlutterWindow : public Win32Window {
13 | public:
14 | // Creates a new FlutterWindow hosting a Flutter view running |project|.
15 | explicit FlutterWindow(const flutter::DartProject& project);
16 | virtual ~FlutterWindow();
17 |
18 | protected:
19 | // Win32Window:
20 | bool OnCreate() override;
21 | void OnDestroy() override;
22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam,
23 | LPARAM const lparam) noexcept override;
24 |
25 | private:
26 | // The project to run.
27 | flutter::DartProject project_;
28 |
29 | // The Flutter instance hosted by this window.
30 | std::unique_ptr flutter_controller_;
31 | };
32 |
33 | #endif // RUNNER_FLUTTER_WINDOW_H_
34 |
--------------------------------------------------------------------------------
/windows/runner/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "flutter_window.h"
6 | #include "utils.h"
7 |
8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
9 | _In_ wchar_t *command_line, _In_ int show_command) {
10 | // Attach to console when present (e.g., 'flutter run') or create a
11 | // new console when running with a debugger.
12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
13 | CreateAndAttachConsole();
14 | }
15 |
16 | // Initialize COM, so that it is available for use in the library and/or
17 | // plugins.
18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
19 |
20 | flutter::DartProject project(L"data");
21 |
22 | std::vector command_line_arguments =
23 | GetCommandLineArguments();
24 |
25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
26 |
27 | FlutterWindow window(project);
28 | Win32Window::Point origin(10, 10);
29 | Win32Window::Size size(360, 480);
30 | if (!window.Create(L"calculator", origin, size)) {
31 | return EXIT_FAILURE;
32 | }
33 | window.SetQuitOnClose(true);
34 |
35 | ::MSG msg;
36 | while (::GetMessage(&msg, nullptr, 0, 0)) {
37 | ::TranslateMessage(&msg);
38 | ::DispatchMessage(&msg);
39 | }
40 |
41 | ::CoUninitialize();
42 | return EXIT_SUCCESS;
43 | }
44 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/windows/runner/resources/app_icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubuntu-flutter-community/calculator/4c0dbbced2b36c2471f41369f79981979a5cd436/windows/runner/resources/app_icon.ico
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 | -1; // remove the trailing null character
52 | int input_length = (int)wcslen(utf16_string);
53 | std::string utf8_string;
54 | if (target_length <= 0 || target_length > utf8_string.max_size()) {
55 | return utf8_string;
56 | }
57 | utf8_string.resize(target_length);
58 | int converted_length = ::WideCharToMultiByte(
59 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
60 | input_length, utf8_string.data(), target_length, nullptr, nullptr);
61 | if (converted_length == 0) {
62 | return std::string();
63 | }
64 | return utf8_string;
65 | }
66 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/windows/runner/win32_window.cpp:
--------------------------------------------------------------------------------
1 | #include "win32_window.h"
2 |
3 | #include
4 | #include
5 |
6 | #include "resource.h"
7 |
8 | namespace {
9 |
10 | /// Window attribute that enables dark mode window decorations.
11 | ///
12 | /// Redefined in case the developer's machine has a Windows SDK older than
13 | /// version 10.0.22000.0.
14 | /// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute
15 | #ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
16 | #define DWMWA_USE_IMMERSIVE_DARK_MODE 20
17 | #endif
18 |
19 | constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW";
20 |
21 | /// Registry key for app theme preference.
22 | ///
23 | /// A value of 0 indicates apps should use dark mode. A non-zero or missing
24 | /// value indicates apps should use light mode.
25 | constexpr const wchar_t kGetPreferredBrightnessRegKey[] =
26 | L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize";
27 | constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme";
28 |
29 | // The number of Win32Window objects that currently exist.
30 | static int g_active_window_count = 0;
31 |
32 | using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd);
33 |
34 | // Scale helper to convert logical scaler values to physical using passed in
35 | // scale factor
36 | int Scale(int source, double scale_factor) {
37 | return static_cast(source * scale_factor);
38 | }
39 |
40 | // Dynamically loads the |EnableNonClientDpiScaling| from the User32 module.
41 | // This API is only needed for PerMonitor V1 awareness mode.
42 | void EnableFullDpiSupportIfAvailable(HWND hwnd) {
43 | HMODULE user32_module = LoadLibraryA("User32.dll");
44 | if (!user32_module) {
45 | return;
46 | }
47 | auto enable_non_client_dpi_scaling =
48 | reinterpret_cast(
49 | GetProcAddress(user32_module, "EnableNonClientDpiScaling"));
50 | if (enable_non_client_dpi_scaling != nullptr) {
51 | enable_non_client_dpi_scaling(hwnd);
52 | }
53 | FreeLibrary(user32_module);
54 | }
55 |
56 | } // namespace
57 |
58 | // Manages the Win32Window's window class registration.
59 | class WindowClassRegistrar {
60 | public:
61 | ~WindowClassRegistrar() = default;
62 |
63 | // Returns the singleton registrar instance.
64 | static WindowClassRegistrar* GetInstance() {
65 | if (!instance_) {
66 | instance_ = new WindowClassRegistrar();
67 | }
68 | return instance_;
69 | }
70 |
71 | // Returns the name of the window class, registering the class if it hasn't
72 | // previously been registered.
73 | const wchar_t* GetWindowClass();
74 |
75 | // Unregisters the window class. Should only be called if there are no
76 | // instances of the window.
77 | void UnregisterWindowClass();
78 |
79 | private:
80 | WindowClassRegistrar() = default;
81 |
82 | static WindowClassRegistrar* instance_;
83 |
84 | bool class_registered_ = false;
85 | };
86 |
87 | WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr;
88 |
89 | const wchar_t* WindowClassRegistrar::GetWindowClass() {
90 | if (!class_registered_) {
91 | WNDCLASS window_class{};
92 | window_class.hCursor = LoadCursor(nullptr, IDC_ARROW);
93 | window_class.lpszClassName = kWindowClassName;
94 | window_class.style = CS_HREDRAW | CS_VREDRAW;
95 | window_class.cbClsExtra = 0;
96 | window_class.cbWndExtra = 0;
97 | window_class.hInstance = GetModuleHandle(nullptr);
98 | window_class.hIcon =
99 | LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON));
100 | window_class.hbrBackground = 0;
101 | window_class.lpszMenuName = nullptr;
102 | window_class.lpfnWndProc = Win32Window::WndProc;
103 | RegisterClass(&window_class);
104 | class_registered_ = true;
105 | }
106 | return kWindowClassName;
107 | }
108 |
109 | void WindowClassRegistrar::UnregisterWindowClass() {
110 | UnregisterClass(kWindowClassName, nullptr);
111 | class_registered_ = false;
112 | }
113 |
114 | Win32Window::Win32Window() {
115 | ++g_active_window_count;
116 | }
117 |
118 | Win32Window::~Win32Window() {
119 | --g_active_window_count;
120 | Destroy();
121 | }
122 |
123 | bool Win32Window::Create(const std::wstring& title,
124 | const Point& origin,
125 | const Size& size) {
126 | Destroy();
127 |
128 | const wchar_t* window_class =
129 | WindowClassRegistrar::GetInstance()->GetWindowClass();
130 |
131 | const POINT target_point = {static_cast(origin.x),
132 | static_cast(origin.y)};
133 | HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST);
134 | UINT dpi = FlutterDesktopGetDpiForMonitor(monitor);
135 | double scale_factor = dpi / 96.0;
136 |
137 | HWND window = CreateWindow(
138 | window_class, title.c_str(), WS_OVERLAPPEDWINDOW,
139 | Scale(origin.x, scale_factor), Scale(origin.y, scale_factor),
140 | Scale(size.width, scale_factor), Scale(size.height, scale_factor),
141 | nullptr, nullptr, GetModuleHandle(nullptr), this);
142 |
143 | if (!window) {
144 | return false;
145 | }
146 |
147 | UpdateTheme(window);
148 |
149 | return OnCreate();
150 | }
151 |
152 | bool Win32Window::Show() {
153 | return ShowWindow(window_handle_, SW_SHOWNORMAL);
154 | }
155 |
156 | // static
157 | LRESULT CALLBACK Win32Window::WndProc(HWND const window,
158 | UINT const message,
159 | WPARAM const wparam,
160 | LPARAM const lparam) noexcept {
161 | if (message == WM_NCCREATE) {
162 | auto window_struct = reinterpret_cast(lparam);
163 | SetWindowLongPtr(window, GWLP_USERDATA,
164 | reinterpret_cast(window_struct->lpCreateParams));
165 |
166 | auto that = static_cast(window_struct->lpCreateParams);
167 | EnableFullDpiSupportIfAvailable(window);
168 | that->window_handle_ = window;
169 | } else if (Win32Window* that = GetThisFromHandle(window)) {
170 | return that->MessageHandler(window, message, wparam, lparam);
171 | }
172 |
173 | return DefWindowProc(window, message, wparam, lparam);
174 | }
175 |
176 | LRESULT
177 | Win32Window::MessageHandler(HWND hwnd,
178 | UINT const message,
179 | WPARAM const wparam,
180 | LPARAM const lparam) noexcept {
181 | switch (message) {
182 | case WM_DESTROY:
183 | window_handle_ = nullptr;
184 | Destroy();
185 | if (quit_on_close_) {
186 | PostQuitMessage(0);
187 | }
188 | return 0;
189 |
190 | case WM_DPICHANGED: {
191 | auto newRectSize = reinterpret_cast(lparam);
192 | LONG newWidth = newRectSize->right - newRectSize->left;
193 | LONG newHeight = newRectSize->bottom - newRectSize->top;
194 |
195 | SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth,
196 | newHeight, SWP_NOZORDER | SWP_NOACTIVATE);
197 |
198 | return 0;
199 | }
200 | case WM_SIZE: {
201 | RECT rect = GetClientArea();
202 | if (child_content_ != nullptr) {
203 | // Size and position the child window.
204 | MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left,
205 | rect.bottom - rect.top, TRUE);
206 | }
207 | return 0;
208 | }
209 |
210 | case WM_ACTIVATE:
211 | if (child_content_ != nullptr) {
212 | SetFocus(child_content_);
213 | }
214 | return 0;
215 |
216 | case WM_DWMCOLORIZATIONCOLORCHANGED:
217 | UpdateTheme(hwnd);
218 | return 0;
219 | }
220 |
221 | return DefWindowProc(window_handle_, message, wparam, lparam);
222 | }
223 |
224 | void Win32Window::Destroy() {
225 | OnDestroy();
226 |
227 | if (window_handle_) {
228 | DestroyWindow(window_handle_);
229 | window_handle_ = nullptr;
230 | }
231 | if (g_active_window_count == 0) {
232 | WindowClassRegistrar::GetInstance()->UnregisterWindowClass();
233 | }
234 | }
235 |
236 | Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept {
237 | return reinterpret_cast(
238 | GetWindowLongPtr(window, GWLP_USERDATA));
239 | }
240 |
241 | void Win32Window::SetChildContent(HWND content) {
242 | child_content_ = content;
243 | SetParent(content, window_handle_);
244 | RECT frame = GetClientArea();
245 |
246 | MoveWindow(content, frame.left, frame.top, frame.right - frame.left,
247 | frame.bottom - frame.top, true);
248 |
249 | SetFocus(child_content_);
250 | }
251 |
252 | RECT Win32Window::GetClientArea() {
253 | RECT frame;
254 | GetClientRect(window_handle_, &frame);
255 | return frame;
256 | }
257 |
258 | HWND Win32Window::GetHandle() {
259 | return window_handle_;
260 | }
261 |
262 | void Win32Window::SetQuitOnClose(bool quit_on_close) {
263 | quit_on_close_ = quit_on_close;
264 | }
265 |
266 | bool Win32Window::OnCreate() {
267 | // No-op; provided for subclasses.
268 | return true;
269 | }
270 |
271 | void Win32Window::OnDestroy() {
272 | // No-op; provided for subclasses.
273 | }
274 |
275 | void Win32Window::UpdateTheme(HWND const window) {
276 | DWORD light_mode;
277 | DWORD light_mode_size = sizeof(light_mode);
278 | LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey,
279 | kGetPreferredBrightnessRegValue,
280 | RRF_RT_REG_DWORD, nullptr, &light_mode,
281 | &light_mode_size);
282 |
283 | if (result == ERROR_SUCCESS) {
284 | BOOL enable_dark_mode = light_mode == 0;
285 | DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE,
286 | &enable_dark_mode, sizeof(enable_dark_mode));
287 | }
288 | }
289 |
--------------------------------------------------------------------------------
/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 a win32 window with |title| that is positioned and sized 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 this function will scale the inputted width and height as
35 | // as appropriate for the default monitor. The window is invisible until
36 | // |Show| is called. Returns true if the window was created successfully.
37 | bool Create(const std::wstring& title, const Point& origin, const Size& size);
38 |
39 | // Show the current window. Returns true if the window was successfully shown.
40 | bool Show();
41 |
42 | // Release OS resources associated with window.
43 | void Destroy();
44 |
45 | // Inserts |content| into the window tree.
46 | void SetChildContent(HWND content);
47 |
48 | // Returns the backing Window handle to enable clients to set icon and other
49 | // window properties. Returns nullptr if the window has been destroyed.
50 | HWND GetHandle();
51 |
52 | // If true, closing this window will quit the application.
53 | void SetQuitOnClose(bool quit_on_close);
54 |
55 | // Return a RECT representing the bounds of the current client area.
56 | RECT GetClientArea();
57 |
58 | protected:
59 | // Processes and route salient window messages for mouse handling,
60 | // size change and DPI. Delegates handling of these to member overloads that
61 | // inheriting classes can handle.
62 | virtual LRESULT MessageHandler(HWND window,
63 | UINT const message,
64 | WPARAM const wparam,
65 | LPARAM const lparam) noexcept;
66 |
67 | // Called when CreateAndShow is called, allowing subclass window-related
68 | // setup. Subclasses should return false if setup fails.
69 | virtual bool OnCreate();
70 |
71 | // Called when Destroy is called.
72 | virtual void OnDestroy();
73 |
74 | private:
75 | friend class WindowClassRegistrar;
76 |
77 | // OS callback called by message pump. Handles the WM_NCCREATE message which
78 | // is passed when the non-client area is being created and enables automatic
79 | // non-client DPI scaling so that the non-client area automatically
80 | // responds to changes in DPI. All other messages are handled by
81 | // MessageHandler.
82 | static LRESULT CALLBACK WndProc(HWND const window,
83 | UINT const message,
84 | WPARAM const wparam,
85 | LPARAM const lparam) noexcept;
86 |
87 | // Retrieves a class instance pointer for |window|
88 | static Win32Window* GetThisFromHandle(HWND const window) noexcept;
89 |
90 | // Update the window frame's theme to match the system theme.
91 | static void UpdateTheme(HWND const window);
92 |
93 | bool quit_on_close_ = false;
94 |
95 | // window handle for top level window.
96 | HWND window_handle_ = nullptr;
97 |
98 | // window handle for hosted content.
99 | HWND child_content_ = nullptr;
100 | };
101 |
102 | #endif // RUNNER_WIN32_WINDOW_H_
103 |
--------------------------------------------------------------------------------