Skip to content

Commit 04eb599

Browse files
committed
Recreate example project native files
1 parent 5f9eba8 commit 04eb599

39 files changed

+495
-178
lines changed

example/.metadata

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,42 @@
44
# This file should be version controlled and should not be manually edited.
55

66
version:
7-
revision: 7a4c33425ddd78c54aba07d86f3f9a4a0051769b
8-
channel: stable
7+
revision: "17025dd88227cd9532c33fa78f5250d548d87e9a"
8+
channel: "stable"
99

1010
project_type: app
11+
12+
# Tracks metadata for the flutter migrate command
13+
migration:
14+
platforms:
15+
- platform: root
16+
create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
17+
base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
18+
- platform: android
19+
create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
20+
base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
21+
- platform: ios
22+
create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
23+
base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
24+
- platform: linux
25+
create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
26+
base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
27+
- platform: macos
28+
create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
29+
base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
30+
- platform: web
31+
create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
32+
base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
33+
- platform: windows
34+
create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
35+
base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
36+
37+
# User provided section
38+
39+
# List of Local paths (relative to this file) that should be
40+
# ignored by the migrate tool.
41+
#
42+
# Files that are not part of the templates will be ignored by default.
43+
unmanaged_files:
44+
- 'lib/main.dart'
45+
- 'ios/Runner.xcodeproj/project.pbxproj'
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.example.example
2+
3+
import io.flutter.embedding.android.FlutterActivity
4+
5+
class MainActivity: FlutterActivity()

example/android/app/src/main/kotlin/com/example/maps_launcher_example/MainActivity.kt

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Flutter
2+
import UIKit
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+
}

example/linux/CMakeLists.txt

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1-
cmake_minimum_required(VERSION 3.10)
1+
# Project-level configuration.
2+
cmake_minimum_required(VERSION 3.13)
23
project(runner LANGUAGES CXX)
34

4-
set(BINARY_NAME "maps_launcher_example")
5-
set(APPLICATION_ID "com.example.maps_launcher")
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 "example")
8+
# The unique GTK application identifier for this application. See:
9+
# https://wiki.gnome.org/HowDoI/ChooseApplicationID
10+
set(APPLICATION_ID "com.example.example")
611

12+
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
13+
# versions of CMake.
714
cmake_policy(SET CMP0063 NEW)
815

16+
# Load bundled libraries from the lib/ directory relative to the binary.
917
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
1018

1119
# Root filesystem for cross-building.
@@ -18,7 +26,7 @@ if(FLUTTER_TARGET_PLATFORM_SYSROOT)
1826
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
1927
endif()
2028

21-
# Configure build options.
29+
# Define build configuration options.
2230
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
2331
set(CMAKE_BUILD_TYPE "Debug" CACHE
2432
STRING "Flutter build mode" FORCE)
@@ -27,34 +35,31 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
2735
endif()
2836

2937
# 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.
3042
function(APPLY_STANDARD_SETTINGS TARGET)
3143
target_compile_features(${TARGET} PUBLIC cxx_std_14)
3244
target_compile_options(${TARGET} PRIVATE -Wall -Werror)
3345
target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>")
3446
target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>")
3547
endfunction()
3648

37-
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
38-
3949
# Flutter library and tool build rules.
50+
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
4051
add_subdirectory(${FLUTTER_MANAGED_DIR})
4152

4253
# System-level dependencies.
4354
find_package(PkgConfig REQUIRED)
4455
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
4556

46-
add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
57+
# Application build; see runner/CMakeLists.txt.
58+
add_subdirectory("runner")
4759

48-
# Application build
49-
add_executable(${BINARY_NAME}
50-
"main.cc"
51-
"my_application.cc"
52-
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
53-
)
54-
apply_standard_settings(${BINARY_NAME})
55-
target_link_libraries(${BINARY_NAME} PRIVATE flutter)
56-
target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
60+
# Run the Flutter tool portions of the build. This must not be removed.
5761
add_dependencies(${BINARY_NAME} flutter_assemble)
62+
5863
# Only the install-generated bundle's copy of the executable will launch
5964
# correctly, since the resources must in the right relative locations. To avoid
6065
# people trying to run the unbundled copy, put it in a subdirectory instead of
@@ -64,6 +69,7 @@ set_target_properties(${BINARY_NAME}
6469
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
6570
)
6671

72+
6773
# Generated plugin build rules, which manage building the plugins and adding
6874
# them to the application.
6975
include(flutter/generated_plugins.cmake)
@@ -94,11 +100,17 @@ install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}
94100
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
95101
COMPONENT Runtime)
96102

97-
if(PLUGIN_BUNDLED_LIBRARIES)
98-
install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
103+
foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES})
104+
install(FILES "${bundled_library}"
99105
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
100106
COMPONENT Runtime)
101-
endif()
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)
102114

103115
# Fully re-copy the assets directory on each build to avoid having stale files
104116
# from a previous install.

example/linux/flutter/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# This file controls Flutter-level build steps. It should not be edited.
12
cmake_minimum_required(VERSION 3.10)
23

34
set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
cmake_minimum_required(VERSION 3.13)
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}
10+
"main.cc"
11+
"my_application.cc"
12+
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
13+
)
14+
15+
# Apply the standard set of build settings. This can be removed for applications
16+
# that need different build settings.
17+
apply_standard_settings(${BINARY_NAME})
18+
19+
# Add preprocessor definitions for the application ID.
20+
add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
21+
22+
# Add dependency libraries. Add any application-specific dependencies here.
23+
target_link_libraries(${BINARY_NAME} PRIVATE flutter)
24+
target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
25+
26+
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ static void my_application_activate(GApplication* application) {
4040
if (use_header_bar) {
4141
GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
4242
gtk_widget_show(GTK_WIDGET(header_bar));
43-
gtk_header_bar_set_title(header_bar, "maps_launcher_example");
43+
gtk_header_bar_set_title(header_bar, "example");
4444
gtk_header_bar_set_show_close_button(header_bar, TRUE);
4545
gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
4646
} else {
47-
gtk_window_set_title(window, "maps_launcher_example");
47+
gtk_window_set_title(window, "example");
4848
}
4949

5050
gtk_window_set_default_size(window, 1280, 720);
@@ -81,6 +81,24 @@ static gboolean my_application_local_command_line(GApplication* application, gch
8181
return TRUE;
8282
}
8383

84+
// Implements GApplication::startup.
85+
static void my_application_startup(GApplication* application) {
86+
//MyApplication* self = MY_APPLICATION(object);
87+
88+
// Perform any actions required at application startup.
89+
90+
G_APPLICATION_CLASS(my_application_parent_class)->startup(application);
91+
}
92+
93+
// Implements GApplication::shutdown.
94+
static void my_application_shutdown(GApplication* application) {
95+
//MyApplication* self = MY_APPLICATION(object);
96+
97+
// Perform any actions required at application shutdown.
98+
99+
G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application);
100+
}
101+
84102
// Implements GObject::dispose.
85103
static void my_application_dispose(GObject* object) {
86104
MyApplication* self = MY_APPLICATION(object);
@@ -91,12 +109,20 @@ static void my_application_dispose(GObject* object) {
91109
static void my_application_class_init(MyApplicationClass* klass) {
92110
G_APPLICATION_CLASS(klass)->activate = my_application_activate;
93111
G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line;
112+
G_APPLICATION_CLASS(klass)->startup = my_application_startup;
113+
G_APPLICATION_CLASS(klass)->shutdown = my_application_shutdown;
94114
G_OBJECT_CLASS(klass)->dispose = my_application_dispose;
95115
}
96116

97117
static void my_application_init(MyApplication* self) {}
98118

99119
MyApplication* my_application_new() {
120+
// Set the program name to the application ID, which helps various systems
121+
// like GTK and desktop environments map this running application to its
122+
// corresponding .desktop file. This ensures better integration by allowing
123+
// the application to be recognized beyond its binary name.
124+
g_set_prgname(APPLICATION_ID);
125+
100126
return MY_APPLICATION(g_object_new(my_application_get_type(),
101127
"application-id", APPLICATION_ID,
102128
"flags", G_APPLICATION_NON_UNIQUE,

0 commit comments

Comments
 (0)