Skip to content

Commit 031310d

Browse files
committed
Regenerate Windows folder in the example
1 parent d4b0609 commit 031310d

13 files changed

Lines changed: 187 additions & 109 deletions

File tree

packages/package_info_plus/package_info_plus/example/windows/CMakeLists.txt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Project-level configuration.
22
cmake_minimum_required(VERSION 3.14)
3-
project(example LANGUAGES CXX)
3+
project(package_info_plus_example LANGUAGES CXX)
44

55
# The name of the executable created for the application. Change this to change
66
# the on-disk name of your application.
7-
set(BINARY_NAME "example")
7+
set(BINARY_NAME "package_info_plus_example")
88

99
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
1010
# versions of CMake.
11-
cmake_policy(SET CMP0063 NEW)
11+
cmake_policy(VERSION 3.14...3.25)
1212

1313
# Define build configuration option.
1414
get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
@@ -52,6 +52,7 @@ add_subdirectory(${FLUTTER_MANAGED_DIR})
5252
# Application build; see runner/CMakeLists.txt.
5353
add_subdirectory("runner")
5454

55+
5556
# Generated plugin build rules, which manage building the plugins and adding
5657
# them to the application.
5758
include(flutter/generated_plugins.cmake)
@@ -86,6 +87,12 @@ if(PLUGIN_BUNDLED_LIBRARIES)
8687
COMPONENT Runtime)
8788
endif()
8889

90+
# Copy the native assets provided by the build.dart from all packages.
91+
set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/")
92+
install(DIRECTORY "${NATIVE_ASSETS_DIR}"
93+
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
94+
COMPONENT Runtime)
95+
8996
# Fully re-copy the assets directory on each build to avoid having stale files
9097
# from a previous install.
9198
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")

packages/package_info_plus/package_info_plus/example/windows/flutter/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ include(${EPHEMERAL_DIR}/generated_config.cmake)
1010
# https://github.com/flutter/flutter/issues/57146.
1111
set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")
1212

13+
# Set fallback configurations for older versions of the flutter tool.
14+
if (NOT DEFINED FLUTTER_TARGET_PLATFORM)
15+
set(FLUTTER_TARGET_PLATFORM "windows-x64")
16+
endif()
17+
1318
# === Flutter Library ===
1419
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")
1520

@@ -92,7 +97,7 @@ add_custom_command(
9297
COMMAND ${CMAKE_COMMAND} -E env
9398
${FLUTTER_TOOL_ENVIRONMENT}
9499
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
95-
windows-x64 $<CONFIG>
100+
${FLUTTER_TARGET_PLATFORM} $<CONFIG>
96101
VERBATIM
97102
)
98103
add_custom_target(flutter_assemble DEPENDS

packages/package_info_plus/package_info_plus/example/windows/runner/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
3333
# Add dependency libraries and include directories. Add any application-specific
3434
# dependencies here.
3535
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
36+
target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib")
3637
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
3738

3839
# Run the Flutter tool portions of the build. This must not be removed.

packages/package_info_plus/package_info_plus/example/windows/runner/Runner.rc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ BEGIN
8989
BEGIN
9090
BLOCK "040904e4"
9191
BEGIN
92-
VALUE "CompanyName", "io.flutter.plugins" "\0"
93-
VALUE "FileDescription", "example" "\0"
92+
VALUE "CompanyName", "io.flutter.plugins.packageinfoplusexample" "\0"
93+
VALUE "FileDescription", "package_info_plus_example" "\0"
9494
VALUE "FileVersion", VERSION_AS_STRING "\0"
95-
VALUE "InternalName", "example" "\0"
96-
VALUE "LegalCopyright", "Copyright (C) 2022 io.flutter.plugins. All rights reserved." "\0"
97-
VALUE "OriginalFilename", "example.exe" "\0"
98-
VALUE "ProductName", "example" "\0"
95+
VALUE "InternalName", "package_info_plus_example" "\0"
96+
VALUE "LegalCopyright", "Copyright (C) 2026 io.flutter.plugins.packageinfoplusexample. All rights reserved." "\0"
97+
VALUE "OriginalFilename", "package_info_plus_example.exe" "\0"
98+
VALUE "ProductName", "package_info_plus_example" "\0"
9999
VALUE "ProductVersion", VERSION_AS_STRING "\0"
100100
END
101101
END

packages/package_info_plus/package_info_plus/example/windows/runner/flutter_window.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include "flutter/generated_plugin_registrant.h"
66

7-
FlutterWindow::FlutterWindow(const flutter::DartProject &project)
7+
FlutterWindow::FlutterWindow(const flutter::DartProject& project)
88
: project_(project) {}
99

1010
FlutterWindow::~FlutterWindow() {}
@@ -26,6 +26,16 @@ bool FlutterWindow::OnCreate() {
2626
}
2727
RegisterPlugins(flutter_controller_->engine());
2828
SetChildContent(flutter_controller_->view()->GetNativeWindow());
29+
30+
flutter_controller_->engine()->SetNextFrameCallback([&]() {
31+
this->Show();
32+
});
33+
34+
// Flutter can complete the first frame before the "show window" callback is
35+
// registered. The following call ensures a frame is pending to ensure the
36+
// window is shown. It is a no-op if the first frame hasn't completed yet.
37+
flutter_controller_->ForceRedraw();
38+
2939
return true;
3040
}
3141

@@ -52,9 +62,9 @@ FlutterWindow::MessageHandler(HWND hwnd, UINT const message,
5262
}
5363

5464
switch (message) {
55-
case WM_FONTCHANGE:
56-
flutter_controller_->engine()->ReloadSystemFonts();
57-
break;
65+
case WM_FONTCHANGE:
66+
flutter_controller_->engine()->ReloadSystemFonts();
67+
break;
5868
}
5969

6070
return Win32Window::MessageHandler(hwnd, message, wparam, lparam);

packages/package_info_plus/package_info_plus/example/windows/runner/flutter_window.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,24 @@
1010

1111
// A window that does nothing but host a Flutter view.
1212
class FlutterWindow : public Win32Window {
13-
public:
13+
public:
1414
// Creates a new FlutterWindow hosting a Flutter view running |project|.
15-
explicit FlutterWindow(const flutter::DartProject &project);
15+
explicit FlutterWindow(const flutter::DartProject& project);
1616
virtual ~FlutterWindow();
1717

18-
protected:
18+
protected:
1919
// Win32Window:
2020
bool OnCreate() override;
2121
void OnDestroy() override;
2222
LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam,
2323
LPARAM const lparam) noexcept override;
2424

25-
private:
25+
private:
2626
// The project to run.
2727
flutter::DartProject project_;
2828

2929
// The Flutter instance hosted by this window.
3030
std::unique_ptr<flutter::FlutterViewController> flutter_controller_;
3131
};
3232

33-
#endif // RUNNER_FLUTTER_WINDOW_H_
33+
#endif // RUNNER_FLUTTER_WINDOW_H_

packages/package_info_plus/package_info_plus/example/windows/runner/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
1919

2020
flutter::DartProject project(L"data");
2121

22-
std::vector<std::string> command_line_arguments = GetCommandLineArguments();
22+
std::vector<std::string> command_line_arguments =
23+
GetCommandLineArguments();
2324

2425
project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
2526

2627
FlutterWindow window(project);
2728
Win32Window::Point origin(10, 10);
2829
Win32Window::Size size(1280, 720);
29-
if (!window.CreateAndShow(L"example", origin, size)) {
30+
if (!window.Create(L"package_info_plus_example", origin, size)) {
3031
return EXIT_FAILURE;
3132
}
3233
window.SetQuitOnClose(true);

packages/package_info_plus/package_info_plus/example/windows/runner/resource.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
// Microsoft Visual C++ generated include file.
33
// Used by Runner.rc
44
//
5-
#define IDI_APP_ICON 101
5+
#define IDI_APP_ICON 101
66

77
// Next default values for new objects
88
//
99
#ifdef APSTUDIO_INVOKED
1010
#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
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
1515
#endif
1616
#endif

packages/package_info_plus/package_info_plus/example/windows/runner/runner.exe.manifest

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99
<application>
1010
<!-- Windows 10 and Windows 11 -->
1111
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
12-
<!-- Windows 8.1 -->
13-
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
14-
<!-- Windows 8 -->
15-
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
16-
<!-- Windows 7 -->
17-
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
1812
</application>
1913
</compatibility>
2014
</assembly>

packages/package_info_plus/package_info_plus/example/windows/runner/utils.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void CreateAndAttachConsole() {
2424
std::vector<std::string> GetCommandLineArguments() {
2525
// Convert the UTF-16 command line arguments to UTF-8 for the Engine to use.
2626
int argc;
27-
wchar_t **argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
27+
wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
2828
if (argv == nullptr) {
2929
return std::vector<std::string>();
3030
}
@@ -41,21 +41,23 @@ std::vector<std::string> GetCommandLineArguments() {
4141
return command_line_arguments;
4242
}
4343

44-
std::string Utf8FromUtf16(const wchar_t *utf16_string) {
44+
std::string Utf8FromUtf16(const wchar_t* utf16_string) {
4545
if (utf16_string == nullptr) {
4646
return std::string();
4747
}
48-
int target_length =
49-
::WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, -1,
50-
nullptr, 0, nullptr, nullptr);
48+
unsigned 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);
5153
std::string utf8_string;
5254
if (target_length == 0 || target_length > utf8_string.max_size()) {
5355
return utf8_string;
5456
}
5557
utf8_string.resize(target_length);
5658
int converted_length = ::WideCharToMultiByte(
57-
CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, -1, utf8_string.data(),
58-
target_length, nullptr, nullptr);
59+
CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
60+
input_length, utf8_string.data(), target_length, nullptr, nullptr);
5961
if (converted_length == 0) {
6062
return std::string();
6163
}

0 commit comments

Comments
 (0)