简体   繁体   中英

Flutter window_utils not compiling code and giving CMakeLists.txt file error

I am using window_utils flutter plugin in my flutter desktop application. When I run my app I got this error Image 1 .

This is my pubspec.yaml code Image 2 .

https://pub.dev/documentation/window_utils/latest/

I tried all versions of this plugin but not working. Can anyone help me what is the issue and how to resolve.

The issue is that that plugin was written against a very early pre-release version of Flutter's desktop support, before the plugin build system and APIs were at all stabilized. Unfortunately it was published despite the clear warning against doing so at the time, and then, predictably, stopped working very shortly thereafter when the next breaking change happened. Since it was not updated after that point, it has never worked since.

There is no way to resolve it other than either forking it and rewriting it for the final version of the plugin system (including completely replacing its build system), or using a different plugin.

Although the plugin is out of date, the C++ code for Windows can still work.

You can find the source code at pub.dartlang.org\window_utils-1.0.2\windows .

在此处输入图像描述

Create a new plugin project with the latest Flutter SDK by yourself:

flutter create --template=plugin --platforms=windows test

Define a Flutter method in lib.dart :

static Future<void> hideTitleBar() async {
    await _channel.invokeMethod('hideTitleBar');
  }

Add the C++ code to *.cpp file:

void FlutterBarcodeSdkPlugin::HandleMethodCall(
      const flutter::MethodCall<flutter::EncodableValue> &method_call,
      std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result)
  {

    if (method_call.method_name().compare("hideTitleBar") == 0)
    {
      HWND hWnd = GetActiveWindow();
      SetMenu(hWnd, NULL);
      LONG lStyle = GetWindowLong(hWnd, GWL_STYLE);
      // lStyle &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU);
      // lStyle &= WS_DLGFRAME;
      lStyle &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU | WS_DLGFRAME);
      SetWindowLong(hWnd, GWL_STYLE, lStyle);
      LONG flags = SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER;
      SetWindowPos(hWnd, NULL, 0, 0, 0, 0, flags);
      flutter::EncodableValue response(true);
      result->Success(&response);
    }
}

I've tested it in my app.

Before hiding the title bar:

在此处输入图像描述

After hiding the title bar:

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM