Flutter messaging classes and their native platform peers

Communication between Flutter modules and Mobile Native code happens over platform channels.  The docs are all over the place so I created this cheat sheet for the different channel types and their class documentation.

YouTube walkthrough video

Mobile Native Communication

Communication between the Mobile native code and Flutter happens over platform channels. Web communication happens via window messaging.

Flutter Channel types

There are three native platform channel types. V1 of this application uses the Message Channel

Channel type and Flutter classDescriptionFlutter
MethodInvoke method on the other sideYesYesVia result
MessageSends a message to a remote listenerYesYesVia reply
EventStreams and sinks. Events can flow in both directionsYesYesN/A

Channel Implementation Classes

Dart/Flutter, Android, and iOS have corresponding `channel` classes for each channel type. The three platform channel implementation classes in Flutter, iOS and, Android are:

Flutter ClassiOS ClassAndroid Class

Method Channel Codecs MethodCodec

Method channels a method on the opposite side.  Method channels use MethodCode implementations.

Flutter Codec ClassiOS Codec ClassAndroid Codec Class
MethodCodec Interface......

Message Channel Codecs

Message channels use MessageCodec Implementations.  Messages are a single payload with an optional return value. Uses codecs shown below.

Flutter Codec ClassiOS Codec ClassAndroid Codec Class
MessageCodec Interface......

Event Channel

Event channels are continuous broadcast streams that use a MethodCodec. Some future blog will describe Event Channels.

Flutter Codec ClassiOS Codec ClassAndroid Codec Class
See MethodCodecSee MethodCodecSee MethodCodec

Platform-specific implementations

Additional details are available for each platform implementation in the sample code in the referenced repository. From README.md in GitHub repository

Web application with message communication between Flutter and Web
Android application with message communication between Flutter and Android
iOS application with message communication between Flutter and Android

YouTube Video

Revision History

Created 2024 07 - copied from the readme and manually reformatted


Popular posts from this blog

Understanding your WSL2 RAM and swap - Changing the default 50%-25%

Installing the RNDIS driver on Windows 11 to use USB Raspberry Pi as network attached

DNS for Azure Point to Site (P2S) VPN - getting the internal IPs