Skip to content

Commit 9821bf6

Browse files
committed
Add multiple window Flutter example project
Introduces a new example Flutter project demonstrating multiple window support. Includes source code, platform-specific files for Linux, macOS, and Windows, configuration files, and initial test setup.
1 parent a7aadb2 commit 9821bf6

64 files changed

Lines changed: 3521 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.build/
9+
.buildlog/
10+
.history
11+
.svn/
12+
.swiftpm/
13+
migrate_working_dir/
14+
15+
# IntelliJ related
16+
*.iml
17+
*.ipr
18+
*.iws
19+
.idea/
20+
21+
# The .vscode folder contains launch configuration and tasks you configure in
22+
# VS Code which you may wish to be included in version control, so this line
23+
# is commented out by default.
24+
#.vscode/
25+
26+
# Flutter/Dart/Pub related
27+
**/doc/api/
28+
**/ios/Flutter/.last_build_id
29+
.dart_tool/
30+
.flutter-plugins-dependencies
31+
.pub-cache/
32+
.pub/
33+
/build/
34+
/coverage/
35+
36+
# Symbolication related
37+
app.*.symbols
38+
39+
# Obfuscation related
40+
app.*.map.json
41+
42+
# Android Studio will place build artifacts here
43+
/android/app/debug
44+
/android/app/profile
45+
/android/app/release
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: "7cf0dc1be72e210be46105c9c8c9196dafba77dd"
8+
channel: "main"
9+
10+
project_type: app
11+
12+
# Tracks metadata for the flutter migrate command
13+
migration:
14+
platforms:
15+
- platform: root
16+
create_revision: 7cf0dc1be72e210be46105c9c8c9196dafba77dd
17+
base_revision: 7cf0dc1be72e210be46105c9c8c9196dafba77dd
18+
- platform: linux
19+
create_revision: 7cf0dc1be72e210be46105c9c8c9196dafba77dd
20+
base_revision: 7cf0dc1be72e210be46105c9c8c9196dafba77dd
21+
- platform: macos
22+
create_revision: 7cf0dc1be72e210be46105c9c8c9196dafba77dd
23+
base_revision: 7cf0dc1be72e210be46105c9c8c9196dafba77dd
24+
- platform: windows
25+
create_revision: 7cf0dc1be72e210be46105c9c8c9196dafba77dd
26+
base_revision: 7cf0dc1be72e210be46105c9c8c9196dafba77dd
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'
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# multiple_window_example
2+
3+
A new Flutter project.
4+
5+
## Getting Started
6+
7+
This project is a starting point for a Flutter application.
8+
9+
A few resources to get you started if this is your first Flutter project:
10+
11+
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
12+
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
13+
14+
For help getting started with Flutter development, view the
15+
[online documentation](https://docs.flutter.dev/), which offers tutorials,
16+
samples, guidance on mobile development, and a full API reference.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This file configures the analyzer, which statically analyzes Dart code to
2+
# check for errors, warnings, and lints.
3+
#
4+
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5+
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6+
# invoked from the command line by running `flutter analyze`.
7+
8+
# The following line activates a set of recommended lints for Flutter apps,
9+
# packages, and plugins designed to encourage good coding practices.
10+
include: package:flutter_lints/flutter.yaml
11+
12+
linter:
13+
# The lint rules applied to this project can be customized in the
14+
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
15+
# included above or to enable additional rules. A list of all available lints
16+
# and their documentation is published at https://dart.dev/lints.
17+
#
18+
# Instead of disabling a lint rule for the entire project in the
19+
# section below, it can also be suppressed for a single line of code
20+
# or a specific dart file by using the `// ignore: name_of_lint` and
21+
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
22+
# producing the lint.
23+
rules:
24+
# avoid_print: false # Uncomment to disable the `avoid_print` rule
25+
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
26+
27+
# Additional information about this file can be found at
28+
# https://dart.dev/guides/language/analysis-options
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
import 'package:flutter/material.dart';
2+
3+
void main() {
4+
runApp(const MyApp());
5+
}
6+
7+
class MyApp extends StatelessWidget {
8+
const MyApp({super.key});
9+
10+
// This widget is the root of your application.
11+
@override
12+
Widget build(BuildContext context) {
13+
return MaterialApp(
14+
title: 'Flutter Demo',
15+
theme: ThemeData(
16+
// This is the theme of your application.
17+
//
18+
// TRY THIS: Try running your application with "flutter run". You'll see
19+
// the application has a purple toolbar. Then, without quitting the app,
20+
// try changing the seedColor in the colorScheme below to Colors.green
21+
// and then invoke "hot reload" (save your changes or press the "hot
22+
// reload" button in a Flutter-supported IDE, or press "r" if you used
23+
// the command line to start the app).
24+
//
25+
// Notice that the counter didn't reset back to zero; the application
26+
// state is not lost during the reload. To reset the state, use hot
27+
// restart instead.
28+
//
29+
// This works for code too, not just values: Most code changes can be
30+
// tested with just a hot reload.
31+
colorScheme: .fromSeed(seedColor: Colors.deepPurple),
32+
),
33+
home: const MyHomePage(title: 'Flutter Demo Home Page'),
34+
);
35+
}
36+
}
37+
38+
class MyHomePage extends StatefulWidget {
39+
const MyHomePage({super.key, required this.title});
40+
41+
// This widget is the home page of your application. It is stateful, meaning
42+
// that it has a State object (defined below) that contains fields that affect
43+
// how it looks.
44+
45+
// This class is the configuration for the state. It holds the values (in this
46+
// case the title) provided by the parent (in this case the App widget) and
47+
// used by the build method of the State. Fields in a Widget subclass are
48+
// always marked "final".
49+
50+
final String title;
51+
52+
@override
53+
State<MyHomePage> createState() => _MyHomePageState();
54+
}
55+
56+
class _MyHomePageState extends State<MyHomePage> {
57+
int _counter = 0;
58+
59+
void _incrementCounter() {
60+
setState(() {
61+
// This call to setState tells the Flutter framework that something has
62+
// changed in this State, which causes it to rerun the build method below
63+
// so that the display can reflect the updated values. If we changed
64+
// _counter without calling setState(), then the build method would not be
65+
// called again, and so nothing would appear to happen.
66+
_counter++;
67+
});
68+
}
69+
70+
@override
71+
Widget build(BuildContext context) {
72+
// This method is rerun every time setState is called, for instance as done
73+
// by the _incrementCounter method above.
74+
//
75+
// The Flutter framework has been optimized to make rerunning build methods
76+
// fast, so that you can just rebuild anything that needs updating rather
77+
// than having to individually change instances of widgets.
78+
return Scaffold(
79+
appBar: AppBar(
80+
// TRY THIS: Try changing the color here to a specific color (to
81+
// Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
82+
// change color while the other colors stay the same.
83+
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
84+
// Here we take the value from the MyHomePage object that was created by
85+
// the App.build method, and use it to set our appbar title.
86+
title: Text(widget.title),
87+
),
88+
body: Center(
89+
// Center is a layout widget. It takes a single child and positions it
90+
// in the middle of the parent.
91+
child: Column(
92+
// Column is also a layout widget. It takes a list of children and
93+
// arranges them vertically. By default, it sizes itself to fit its
94+
// children horizontally, and tries to be as tall as its parent.
95+
//
96+
// Column has various properties to control how it sizes itself and
97+
// how it positions its children. Here we use mainAxisAlignment to
98+
// center the children vertically; the main axis here is the vertical
99+
// axis because Columns are vertical (the cross axis would be
100+
// horizontal).
101+
//
102+
// TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint"
103+
// action in the IDE, or press "p" in the console), to see the
104+
// wireframe for each widget.
105+
mainAxisAlignment: .center,
106+
children: [
107+
const Text('You have pushed the button this many times:'),
108+
Text(
109+
'$_counter',
110+
style: Theme.of(context).textTheme.headlineMedium,
111+
),
112+
],
113+
),
114+
),
115+
floatingActionButton: FloatingActionButton(
116+
onPressed: _incrementCounter,
117+
tooltip: 'Increment',
118+
child: const Icon(Icons.add),
119+
),
120+
);
121+
}
122+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
flutter/ephemeral
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Project-level configuration.
2+
cmake_minimum_required(VERSION 3.13)
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 "multiple_window_example")
8+
# The unique GTK application identifier for this application. See:
9+
# https://wiki.gnome.org/HowDoI/ChooseApplicationID
10+
set(APPLICATION_ID "com.example.multiple_window_example")
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+
# Root filesystem for cross-building.
20+
if(FLUTTER_TARGET_PLATFORM_SYSROOT)
21+
set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT})
22+
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
23+
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
24+
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
25+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
26+
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
27+
endif()
28+
29+
# Define build configuration options.
30+
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
31+
set(CMAKE_BUILD_TYPE "Debug" CACHE
32+
STRING "Flutter build mode" FORCE)
33+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
34+
"Debug" "Profile" "Release")
35+
endif()
36+
37+
# Compilation settings that should be applied to most targets.
38+
#
39+
# Be cautious about adding new options here, as plugins use this function by
40+
# default. In most cases, you should add new options to specific targets instead
41+
# of modifying this function.
42+
function(APPLY_STANDARD_SETTINGS TARGET)
43+
target_compile_features(${TARGET} PUBLIC cxx_std_14)
44+
target_compile_options(${TARGET} PRIVATE -Wall -Werror)
45+
target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>")
46+
target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>")
47+
endfunction()
48+
49+
# Flutter library and tool build rules.
50+
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
51+
add_subdirectory(${FLUTTER_MANAGED_DIR})
52+
53+
# System-level dependencies.
54+
find_package(PkgConfig REQUIRED)
55+
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
56+
57+
# Application build; see runner/CMakeLists.txt.
58+
add_subdirectory("runner")
59+
60+
# Run the Flutter tool portions of the build. This must not be removed.
61+
add_dependencies(${BINARY_NAME} flutter_assemble)
62+
63+
# Only the install-generated bundle's copy of the executable will launch
64+
# correctly, since the resources must in the right relative locations. To avoid
65+
# people trying to run the unbundled copy, put it in a subdirectory instead of
66+
# the default top-level location.
67+
set_target_properties(${BINARY_NAME}
68+
PROPERTIES
69+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
70+
)
71+
72+
73+
# Generated plugin build rules, which manage building the plugins and adding
74+
# them to the application.
75+
include(flutter/generated_plugins.cmake)
76+
77+
78+
# === Installation ===
79+
# By default, "installing" just makes a relocatable bundle in the build
80+
# directory.
81+
set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
82+
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
83+
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
84+
endif()
85+
86+
# Start with a clean build bundle directory every time.
87+
install(CODE "
88+
file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\")
89+
" COMPONENT Runtime)
90+
91+
set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
92+
set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
93+
94+
install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
95+
COMPONENT Runtime)
96+
97+
install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
98+
COMPONENT Runtime)
99+
100+
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
101+
COMPONENT Runtime)
102+
103+
foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES})
104+
install(FILES "${bundled_library}"
105+
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
106+
COMPONENT Runtime)
107+
endforeach(bundled_library)
108+
109+
# Copy the native assets provided by the build.dart from all packages.
110+
set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/")
111+
install(DIRECTORY "${NATIVE_ASSETS_DIR}"
112+
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
113+
COMPONENT Runtime)
114+
115+
# Fully re-copy the assets directory on each build to avoid having stale files
116+
# from a previous install.
117+
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
118+
install(CODE "
119+
file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
120+
" COMPONENT Runtime)
121+
install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
122+
DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
123+
124+
# Install the AOT library on non-Debug builds only.
125+
if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
126+
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
127+
COMPONENT Runtime)
128+
endif()

0 commit comments

Comments
 (0)