How do plugins work on iOS and Android?
Many plugins will work with the different underlying platforms to use OS functionality. This dependency changes the way your project is built and run because there is native code within your project that interfaces with the underlying platform. Let’s look at how that interfacing works.
MethodChannel
Flutter communication between the client (Flutter) and the host (native) application occurs through platform channels. The MethodChannel
class is responsible for sending messages (method invocations) to the platform side. On the platform side, MethodChannel
on Android (API) and FlutterMethodChannel
on iOS (API) allow you to receive method calls and send a result back. The structure of this relationship is shown in the following diagram:
Figure 9.5 – Interface between Flutter and native
The platform channel technique allows you to decouple the UI code from the platform-specific native code. The host...