Open GroovinChip opened 2 years ago
Yup, that's a good call-out. https://github.com/flutter/website/issues/7123 is related...
On the Windows side, https://pub.dev/packages/win32 gets us ever closer to supporting everything you might do with a plugin using just Dart code in a package. It provides solid wrappers for Win32 and COM, we're continuing to develop WinRT support.
I support this so much. I've been struggling so hard. Heck that's how I ended up here lol. I've managed to figure the basic things out using the url_launcher and path_provider packages. Currently struggling with figuring out how, on the c++ side, do I access the data passed from the dart side.
Thanks for this basic guide. Helps me out a ton.
What information is missing?
The Developing Packages & Plugins document should go into more detail about writing plugins for desktop platforms. As a desktop plugin author myself, I have struggled mightily with the nuances of writing a plugin in Swift for macOS, C/C++ for Windows, and C/C++ for Linux (which seems to be different than the C/C++ for Windows). Doing something as simple as reading
PlatformChannel
arguments required a frustrating level of researching. The API docs for the native Flutter platform code (things likeFlutterResult
, etc etc) are super hard to find and are also poorly documented. The only existing codelab for desktop provides zero explanation for the step that covers writing a plugin.Basically, there is little to no documentation available on this subject as it relates to desktop. Given that all three desktop platforms are now officially stable, I believe it is past time for in-depth documentation to be provided by Flutter on writing desktop plugin.
A section of this document that might be good for (some, if not all of) these details is Step 2: Implement the package. Alternatively, it could be its own section, or even its own page.
Here are some of the topics I have struggled with in the past. All code snippets are from a real plugin I'm working on to generate thumbnails from videos:
PlatformChannel
argumentsMap
argumentsMap
arguments back to FlutterMap
argumentsMap
arguments back to FlutterMap
arguments (real code sample):EventChannel
s (not related to the thumbnail plugin)MediaFoundation
library. Linking that library to thewindows
runner was infuriatingly difficult, and it took several days, a lot of research, and help from several people to get this working. It required creating a dedicatedcmake
file to find the library and modifyingCMakeLists.txt
, and the nuances of both of those steps work were hard to figure out. Documentation from Flutter on this would have been quite helpful.ffmpeg
library, but stopped because its such an enormous headache. Again, documentation on this would be super helpful.I'm sure that there are many more nuances related to writing desktop plugins for Flutter that people struggle with.
How would you like us to fix this problem?
Please consider writing in-depth documentation on this subject. I'd be happy to collaborate on this, if desired.