Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 32 additions & 34 deletions packages/device_info_plus/device_info_plus/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -237,44 +237,42 @@ class _MyAppState extends State<MyApp> {
home: Scaffold(
appBar: AppBar(title: Text(_getAppBarTitle()), elevation: 4),
body: ListView(
children:
_deviceData.keys.map((String property) {
return Row(
children: <Widget>[
Container(
padding: const EdgeInsets.all(10),
child: Text(
property,
style: const TextStyle(fontWeight: FontWeight.bold),
),
children: _deviceData.keys.map((String property) {
return Row(
children: <Widget>[
Container(
padding: const EdgeInsets.all(10),
child: Text(
property,
style: const TextStyle(fontWeight: FontWeight.bold),
),
),
Expanded(
child: Container(
padding: const EdgeInsets.symmetric(vertical: 10),
child: Text(
'${_deviceData[property]}',
maxLines: 10,
overflow: TextOverflow.ellipsis,
),
Expanded(
child: Container(
padding: const EdgeInsets.symmetric(vertical: 10),
child: Text(
'${_deviceData[property]}',
maxLines: 10,
overflow: TextOverflow.ellipsis,
),
),
),
],
);
}).toList(),
),
),
],
);
}).toList(),
),
),
);
}

String _getAppBarTitle() =>
kIsWeb
? 'Web Browser info'
: switch (defaultTargetPlatform) {
TargetPlatform.android => 'Android Device Info',
TargetPlatform.iOS => 'iOS Device Info',
TargetPlatform.linux => 'Linux Device Info',
TargetPlatform.windows => 'Windows Device Info',
TargetPlatform.macOS => 'MacOS Device Info',
TargetPlatform.fuchsia => 'Fuchsia Device Info',
};
String _getAppBarTitle() => kIsWeb
? 'Web Browser info'
: switch (defaultTargetPlatform) {
TargetPlatform.android => 'Android Device Info',
TargetPlatform.iOS => 'iOS Device Info',
TargetPlatform.linux => 'Linux Device Info',
TargetPlatform.windows => 'Windows Device Info',
TargetPlatform.macOS => 'MacOS Device Info',
TargetPlatform.fuchsia => 'Fuchsia Device Info',
};
}
8 changes: 4 additions & 4 deletions packages/package_info_plus/package_info_plus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ This Flutter plugin provides an API for querying information about an applicatio

## Requirements

- Flutter >=3.19.0
- Dart >=3.3.0 <4.0.0
- iOS >=12.0
- macOS >=10.14
- Flutter >=3.41.0
- Dart >=3.11.0 <4.0.0
- iOS >=13.0
- macOS >=10.15
- Java 17
- Kotlin 2.2.0
- Android Gradle Plugin >=8.12.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ void main() {
),
);
} else if (Platform.isWindows) {
expect(info.appName, 'example');
expect(info.appName, 'package_info_plus_example');
expect(info.buildNumber, '4');
expect(info.buildSignature, isEmpty);
expect(info.packageName, 'example');
expect(info.packageName, 'package_info_plus_example');
expect(info.version, '1.2.3');
expect(info.installerStore, null);
expect(
Expand Down Expand Up @@ -221,7 +221,7 @@ void main() {
expect(find.text('Not set'), findsOneWidget);
expect(find.textContaining(installTimeRegex), findsNWidgets(2));
} else if (Platform.isWindows) {
expect(find.text('example'), findsNWidgets(2));
expect(find.text('package_info_plus_example'), findsNWidgets(2));
expect(find.text('1.2.3'), findsOneWidget);
expect(find.text('4'), findsOneWidget);
expect(find.text('Not set'), findsOneWidget);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Project-level configuration.
cmake_minimum_required(VERSION 3.14)
project(example LANGUAGES CXX)
project(package_info_plus_example LANGUAGES CXX)

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

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

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


# Generated plugin build rules, which manage building the plugins and adding
# them to the application.
include(flutter/generated_plugins.cmake)
Expand Down Expand Up @@ -86,6 +87,12 @@ if(PLUGIN_BUNDLED_LIBRARIES)
COMPONENT Runtime)
endif()

# Copy the native assets provided by the build.dart from all packages.
set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/")
install(DIRECTORY "${NATIVE_ASSETS_DIR}"
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)

# Fully re-copy the assets directory on each build to avoid having stale files
# from a previous install.
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ include(${EPHEMERAL_DIR}/generated_config.cmake)
# https://github.com/flutter/flutter/issues/57146.
set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")

# Set fallback configurations for older versions of the flutter tool.
if (NOT DEFINED FLUTTER_TARGET_PLATFORM)
set(FLUTTER_TARGET_PLATFORM "windows-x64")
endif()

# === Flutter Library ===
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")

Expand Down Expand Up @@ -92,7 +97,7 @@ add_custom_command(
COMMAND ${CMAKE_COMMAND} -E env
${FLUTTER_TOOL_ENVIRONMENT}
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
windows-x64 $<CONFIG>
${FLUTTER_TARGET_PLATFORM} $<CONFIG>
VERBATIM
)
add_custom_target(flutter_assemble DEPENDS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
# Add dependency libraries and include directories. Add any application-specific
# dependencies here.
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib")
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")

# Run the Flutter tool portions of the build. This must not be removed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ BEGIN
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "CompanyName", "io.flutter.plugins" "\0"
VALUE "FileDescription", "example" "\0"
VALUE "CompanyName", "io.flutter.plugins.packageinfoplusexample" "\0"
VALUE "FileDescription", "package_info_plus_example" "\0"
VALUE "FileVersion", VERSION_AS_STRING "\0"
VALUE "InternalName", "example" "\0"
VALUE "LegalCopyright", "Copyright (C) 2022 io.flutter.plugins. All rights reserved." "\0"
VALUE "OriginalFilename", "example.exe" "\0"
VALUE "ProductName", "example" "\0"
VALUE "InternalName", "package_info_plus_example" "\0"
VALUE "LegalCopyright", "Copyright (C) 2026 io.flutter.plugins.packageinfoplusexample. All rights reserved." "\0"
VALUE "OriginalFilename", "package_info_plus_example.exe" "\0"
VALUE "ProductName", "package_info_plus_example" "\0"
VALUE "ProductVersion", VERSION_AS_STRING "\0"
END
END
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "flutter/generated_plugin_registrant.h"

FlutterWindow::FlutterWindow(const flutter::DartProject &project)
FlutterWindow::FlutterWindow(const flutter::DartProject& project)
: project_(project) {}

FlutterWindow::~FlutterWindow() {}
Expand All @@ -26,6 +26,16 @@ bool FlutterWindow::OnCreate() {
}
RegisterPlugins(flutter_controller_->engine());
SetChildContent(flutter_controller_->view()->GetNativeWindow());

flutter_controller_->engine()->SetNextFrameCallback([&]() {
this->Show();
});

// Flutter can complete the first frame before the "show window" callback is
// registered. The following call ensures a frame is pending to ensure the
// window is shown. It is a no-op if the first frame hasn't completed yet.
flutter_controller_->ForceRedraw();

return true;
}

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

switch (message) {
case WM_FONTCHANGE:
flutter_controller_->engine()->ReloadSystemFonts();
break;
case WM_FONTCHANGE:
flutter_controller_->engine()->ReloadSystemFonts();
break;
}

return Win32Window::MessageHandler(hwnd, message, wparam, lparam);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@

// A window that does nothing but host a Flutter view.
class FlutterWindow : public Win32Window {
public:
public:
// Creates a new FlutterWindow hosting a Flutter view running |project|.
explicit FlutterWindow(const flutter::DartProject &project);
explicit FlutterWindow(const flutter::DartProject& project);
virtual ~FlutterWindow();

protected:
protected:
// Win32Window:
bool OnCreate() override;
void OnDestroy() override;
LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam,
LPARAM const lparam) noexcept override;

private:
private:
// The project to run.
flutter::DartProject project_;

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

#endif // RUNNER_FLUTTER_WINDOW_H_
#endif // RUNNER_FLUTTER_WINDOW_H_
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,

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

std::vector<std::string> command_line_arguments = GetCommandLineArguments();
std::vector<std::string> command_line_arguments =
GetCommandLineArguments();

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

FlutterWindow window(project);
Win32Window::Point origin(10, 10);
Win32Window::Size size(1280, 720);
if (!window.CreateAndShow(L"example", origin, size)) {
if (!window.Create(L"package_info_plus_example", origin, size)) {
return EXIT_FAILURE;
}
window.SetQuitOnClose(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
// Microsoft Visual C++ generated include file.
// Used by Runner.rc
//
#define IDI_APP_ICON 101
#define IDI_APP_ICON 101

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@
<application>
<!-- Windows 10 and Windows 11 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
</application>
</compatibility>
</assembly>
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void CreateAndAttachConsole() {
std::vector<std::string> GetCommandLineArguments() {
// Convert the UTF-16 command line arguments to UTF-8 for the Engine to use.
int argc;
wchar_t **argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
if (argv == nullptr) {
return std::vector<std::string>();
}
Expand All @@ -41,21 +41,23 @@ std::vector<std::string> GetCommandLineArguments() {
return command_line_arguments;
}

std::string Utf8FromUtf16(const wchar_t *utf16_string) {
std::string Utf8FromUtf16(const wchar_t* utf16_string) {
if (utf16_string == nullptr) {
return std::string();
}
int target_length =
::WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, -1,
nullptr, 0, nullptr, nullptr);
unsigned int target_length = ::WideCharToMultiByte(
CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
-1, nullptr, 0, nullptr, nullptr)
-1; // remove the trailing null character
int input_length = (int)wcslen(utf16_string);
std::string utf8_string;
if (target_length == 0 || target_length > utf8_string.max_size()) {
return utf8_string;
}
utf8_string.resize(target_length);
int converted_length = ::WideCharToMultiByte(
CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, -1, utf8_string.data(),
target_length, nullptr, nullptr);
CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
input_length, utf8_string.data(), target_length, nullptr, nullptr);
if (converted_length == 0) {
return std::string();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ void CreateAndAttachConsole();

// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string
// encoded in UTF-8. Returns an empty std::string on failure.
std::string Utf8FromUtf16(const wchar_t *utf16_string);
std::string Utf8FromUtf16(const wchar_t* utf16_string);

// Gets the command line arguments passed in as a std::vector<std::string>,
// encoded in UTF-8. Returns an empty std::vector<std::string> on failure.
std::vector<std::string> GetCommandLineArguments();

#endif // RUNNER_UTILS_H_
#endif // RUNNER_UTILS_H_
Loading
Loading