flutter / website

Flutter documentation web site
https://docs.flutter.dev
Other
2.82k stars 3.23k forks source link

Add more information about developing desktop plugins #7164

Open GroovinChip opened 2 years ago

GroovinChip commented 2 years ago

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 like FlutterResult, 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:

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.

timsneath commented 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.

Chappie74 commented 2 years ago

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.