@@ -31,11 +31,6 @@ bool IsWindows11OrGreater() {
3131 return dwBuild < 22000 ;
3232}
3333
34- std::unique_ptr<
35- flutter::MethodChannel<flutter::EncodableValue>,
36- std::default_delete<flutter::MethodChannel<flutter::EncodableValue>>>
37- channel = nullptr ;
38-
3934class WindowManagerPlugin : public flutter ::Plugin {
4035 public:
4136 static void RegisterWithRegistrar (flutter::PluginRegistrarWindows* registrar);
@@ -45,6 +40,12 @@ class WindowManagerPlugin : public flutter::Plugin {
4540 virtual ~WindowManagerPlugin ();
4641
4742 private:
43+ std::unique_ptr<
44+ flutter::MethodChannel<flutter::EncodableValue>,
45+ std::default_delete<flutter::MethodChannel<flutter::EncodableValue>>>
46+ channel = nullptr ;
47+
48+
4849 WindowManager* window_manager;
4950 flutter::PluginRegistrarWindows* registrar;
5051
@@ -95,17 +96,8 @@ class WindowManagerPlugin : public flutter::Plugin {
9596// static
9697void WindowManagerPlugin::RegisterWithRegistrar (
9798 flutter::PluginRegistrarWindows* registrar) {
98- channel = std::make_unique<flutter::MethodChannel<flutter::EncodableValue>>(
99- registrar->messenger (), " window_manager" ,
100- &flutter::StandardMethodCodec::GetInstance ());
101-
10299 auto plugin = std::make_unique<WindowManagerPlugin>(registrar);
103100
104- channel->SetMethodCallHandler (
105- [plugin_pointer = plugin.get ()](const auto & call, auto result) {
106- plugin_pointer->HandleMethodCall (call, std::move (result));
107- });
108-
109101 registrar->AddPlugin (std::move (plugin));
110102}
111103
@@ -117,6 +109,14 @@ WindowManagerPlugin::WindowManagerPlugin(
117109 [this ](HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
118110 return HandleWindowProc (hWnd, message, wParam, lParam);
119111 });
112+ channel = std::make_unique<flutter::MethodChannel<flutter::EncodableValue>>(
113+ registrar->messenger (), " window_manager" ,
114+ &flutter::StandardMethodCodec::GetInstance ());
115+
116+ channel->SetMethodCallHandler (
117+ [this ](const auto & call, auto result) {
118+ HandleMethodCall (call, std::move (result));
119+ });
120120}
121121
122122WindowManagerPlugin::~WindowManagerPlugin () {
0 commit comments