This tutorial is a Kotlin version of this tutorial: “How To Write a Flutter Plugin” from  Google Developers Colabs. (The original tutorial was written in JAVA.)

The G**oal** of this tutorial is to go through:

  • When do you need a Flutter Plugin project.
  • How does Flutter communicate with Android native code/library in Kotlin. (Read the original tutorial for iOS alternatives).
  • How to config a Flutter Plugin project from scratch with IntelliJ IDEA.
  • Following the original tutorial to build an example app of MIDI keyboard (with Flutter front-end) which uses Android native library: android.media (with Kotlin) through the Flutter Plugin API(with Dart) you will build.

When do you need a Flutter Plugin project?

Flutter Plugin is an advanced topic in Flutter development. Many developers do not need to build Flutter Plugin in their Flutter development. However, if you want to do the following task, you might need one:

  • If you want to build a Flutter API for other Flutter projects to use,
  • and / or through such API, you enable Flutter to communicate with platform-specific native code (e.g., JAVA or Kotlin for Android, and Objective-C or Swift for iOS).

How does Flutter Work?

Before we start the tutorial, we need an introduction of how does Flutter work in general. Flutter is a cross-platform development framework, which allows you to build UI for different platforms, i.e., Android, iOS, or Web (See also  supported platforms), with one code base. Flutter is written in Dart language, and it takes care of the underlying integration for different platforms, so you don’t need to build a separate development, e.g., using Swift for iOS and Kotlin/JAVA for Android, for the same app.

It sounds terrific, isn’t it! Since Flutter is a framework which wraps the native Android and iOS platform-specific codes to make such integration possible, there is an intermediate Dart layer which handles the communication between or . In other words, if you don’t need the Android or iOS native libraries to achieve your task, then you don’t even need to worry about this.

#plugins #flutter #android-app-development

Build Your Own Flutter Plugin For Android Native Kotlin — Part I
2.15 GEEK