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:
@@ -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