kotlin

Solid

Writing the Android-native (Kotlin) side of a Flutter app for features Flutter can't reach — a MethodChannel handler registry, main-looper dispatch, notImplemented defaults, and Native↔Flutter invocation. Auto-applies when editing any Kotlin file.

AI & Automation 1 stars 0 forks Updated yesterday MIT

Install

View on GitHub

Quality Score: 78/100

Stars 20%
10
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

# Android Native (Kotlin) via Platform Channels Use Kotlin only for capabilities Flutter/Dart can't express — Android Auto, app widgets, foreground services, deep OS integrations. Everything crosses the boundary through a `MethodChannel`; keep the native side a thin dispatcher and push logic back into Dart where you can. ## Channel dispatcher One channel per feature as an `object` (singleton). Prefer a **handler registry** keyed by method name so several screens can each register their own methods without overwriting a single monolithic `when` block: ```kotlin package app.carapp import android.os.Handler import android.os.Looper import io.flutter.plugin.common.MethodCall import io.flutter.plugin.common.MethodChannel /// Centralized dispatcher for the com.app/car_extension MethodChannel. object CarAppChannel { private const val CHANNEL_NAME = "com.app/car_extension" private val handlers = mutableMapOf<String, (MethodCall, MethodChannel.Result) -> Unit>() fun registerHandler(method: String, handler: (MethodCall, MethodChannel.Result) -> Unit) { handlers[method] = handler } fun unregisterHandler(method: String) = handlers.remove(method) } ``` - Channel name is a reverse-DNS string shared verbatim with the Dart side — `com.app/<feature>`. Define it once as a `const`. - Each screen calls `registerHandler` in its init and `unregisterHandler` in its cleanup/`onDestroy` — lifecycle owns the handler, not the channel. ## Initialization & Flutter → Native Bi...

Details

Author
virajp
Repository
virajp/ai-plugins
Created
2 months ago
Last Updated
yesterday
Language
JavaScript
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category