Using Pigeon eliminates the need to match
strings between host and client
for the names and datatypes of messages.
It supports: nested classes, grouping
messages into APIs, generation of
asynchronous wrapper code and sending messages
in either direction. The generated code is readable
and guarantees there are no conflicts between
multiple clients of different versions.
Supported languages are Objective-C, Java, Kotlin,
and Swift (with Objective-C interop).

Pigeon example

Pigeon file:

Dart usage:

Separate platform-specific code from UI code

If you expect to use your platform-specific code
in multiple Flutter apps, you might consider
separating the code into a platform plugin located
in a directory outside your main application.
See developing packages for details.

Publish platform-specific code as a package

To share your platform-specific code with other developers
in the Flutter ecosystem, see publishing packages.

Custom channels and codecs