Add windows implementation to platform_view example (#109715)
* Add Windows platform view example * Add new tests for Windows desktop * Add Windows platform view * Use const constructors (linux analyze)\ * Fix spelling/format * Clean up code * Remove default case
This commit is contained in:
@@ -60,6 +60,9 @@ add_subdirectory("runner")
|
||||
# them to the application.
|
||||
include(flutter/generated_plugins.cmake)
|
||||
|
||||
target_include_directories(${BINARY_NAME} INTERFACE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/flutter")
|
||||
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_plugin)
|
||||
|
||||
# === Installation ===
|
||||
# Support files are copied into place next to the executable, so that it can
|
||||
@@ -84,6 +87,7 @@ install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}
|
||||
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
|
||||
COMPONENT Runtime)
|
||||
|
||||
set(PLUGIN_BUNDLED_LIBRARIES)
|
||||
if(PLUGIN_BUNDLED_LIBRARIES)
|
||||
install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
|
||||
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
|
||||
|
||||
@@ -4,10 +4,38 @@
|
||||
|
||||
#include "flutter_window.h"
|
||||
|
||||
#include <WinUser.h>
|
||||
#include <flutter/flutter_engine.h>
|
||||
#include <flutter/method_channel.h>
|
||||
#include <flutter/plugin_registrar_windows.h>
|
||||
#include <flutter/standard_method_codec.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include "flutter/generated_plugin_registrant.h"
|
||||
|
||||
void RegisterMethodChannel(flutter::FlutterEngine* engine) {
|
||||
FlutterDesktopPluginRegistrarRef plugin_registrar_ref =
|
||||
engine->GetRegistrarForPlugin("platform_view");
|
||||
flutter::PluginRegistrarWindows* registrar =
|
||||
flutter::PluginRegistrarManager::GetInstance()
|
||||
->GetRegistrar<flutter::PluginRegistrarWindows>(plugin_registrar_ref);
|
||||
auto channel =
|
||||
std::make_unique<flutter::MethodChannel<flutter::EncodableValue>>(
|
||||
registrar->messenger(), "samples.flutter.io/platform_view",
|
||||
&flutter::StandardMethodCodec::GetInstance());
|
||||
channel->SetMethodCallHandler([](const auto& call, auto result) {
|
||||
int counter = std::get<int32_t>(*call.arguments());
|
||||
std::string msg = std::string("Pressed the button ") +
|
||||
std::to_string(counter) + " times!";
|
||||
MessageBoxA(NULL, msg.c_str(), "Popup", MB_OK);
|
||||
result->Success(flutter::EncodableValue(counter));
|
||||
});
|
||||
}
|
||||
|
||||
FlutterWindow::FlutterWindow(const flutter::DartProject& project)
|
||||
: project_(project) {}
|
||||
|
||||
@@ -29,6 +57,7 @@ bool FlutterWindow::OnCreate() {
|
||||
return false;
|
||||
}
|
||||
RegisterPlugins(flutter_controller_->engine());
|
||||
RegisterMethodChannel(flutter_controller_->engine());
|
||||
SetChildContent(flutter_controller_->view()->GetNativeWindow());
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user