问题
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?
回答1:
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.
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.
来源:https://stackoverflow.com/questions/58632322/flutter-desktop-plugin-for-windows