本文介绍了Flutter Desktop-Windows插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Flutter桌面上的插件寻求帮助.我正在使用 https://github.com/google/flutter-desktop-embedding 开发桌面应用程序.直到我只使用Flutter开箱即用的功能,所有功能都可以正常工作.现在,我必须实现一个缺少的部分(使用外部打印机打印文件).我很努力,因为github存储库中的示例并未给出如何执行此操作的完整视图.有一个windows目录,负责为Windows构建该应用程序的代码在其中.现在,我不知道可以将代码放在哪里开始开发所需的代码. Windows目录如下所示:

I am looking for help with the plugins in the flutter desktop. I am using https://github.com/google/flutter-desktop-embedding to develop the desktop app. Till I was using only the functions that come out of the box with the Flutter all was working fine. Now I have to implement a missing part (printing the file using the external printer). I am struggling because the examples in the github repositories do not give a full vision of how to do that. There is a windows directory where the code responsible for building the app for windows is. Now I do not know where I can put my code to start developing the code that I need. The windows directory looks like this:

在哪里可以放置代码来注册方法通道并处理每个函数的执行?

Where can I put the code to register the Method Channel and the handle each function execution?

推荐答案

如果您实际上是在尝试构建插件,则按照问题的标题,您无需将代码放在该目录中的任何位置;相反,您可以创建插件并将代码放在此处.与应用程序分离是使它成为插件的原因.

If you are actually trying to build a plugin, per the title of your question, you don't put your code anywhere in that directory; instead you would create a plugin and put the code there. Being separate from the application is what makes it a plugin.

如果您只是想将基于MethodChannel的代码直接添加到本机应用程序中,则可以将代码放置在该目录中的任意位置(我建议您使用一个新文件,以使其不会与仍然不稳定的基本文件混在一起.每次更新Flutter时都需要替换的执行器代码.只要您不破坏项目名称或Flutter使用的构建设置之类的核心假设,就可以根据自己的喜好来执行该项目,就像针对移动平台的模板创建的Flutter项目一样.您只需要在main中进行注册即可.紧挨调用生成的行插件注册者将是一个不错的选择.

If you just mean you want to add MethodChannel-based code directly to your native app, you can put the code wherever you like in that directory (I would recommend a new file so that it's not intermixed with the still-volatile basic Runner code that you will need to replace every time you update Flutter). As long as you don't break core assumptions like the name of the project or build settings used by Flutter the project is yours to do what you like with, just as with template-created Flutter projects targeting mobile platforms. You would just need to register it in main. Right next to the line calling the generated plugin registrant would be a good place for that.

这篇关于Flutter Desktop-Windows插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 12:11