
Also, Flutter gives you the required APIs to send data back to Flutter from the native host app code. BasicMessageChannelįlutter offers the MethodChannel Dart class for developers to invoke platform-specific native code from the Flutter environment. Invoking native SDK functions via MethodChannel.Also, I will explain how to do event-driven Flutter-Native communications via EventChannel. In this tutorial, I will explain how to call Kotlin code from the Dart side via the Flutter platform channels’ MethodChannel class. It also offers the platform channels API to communicate with platform-specific code to use operating-system-level APIs or invoke code segments written in the native app development language. But what if you need to call this platform-specific Kotlin code from your Flutter app?įlutter lets you use Dart’s inbuilt cross-platform standard library for general-purpose programming requirements (i.e., I/O, Math, etc.).

You can use your existing Kotlin/Java-based shared libraries within native Kotlin-based Android apps. For example, if you build a native Android app with Kotlin, you can use the Vibratorclass from the Android SDK to make the user’s device vibrate. Shalitha Suranga Follow Programmer | Author of Neutralino.js | Technical Writer Using Flutter’s MethodChannel to invoke Kotlin code for Androidĭeveloping a Flutter mobile app involves rendering some UI elements that get changed according to the user-initiated touch events , so we often need to use the user device’s hardware components via platform-specific SDKs.Įvery mobile platform offers inbuilt APIs to access hardware components and core operating system features.
