flutter-native-interop
Installation
SKILL.md
Flutter Platform Integration
Goal
Integrates Flutter applications with platform-specific code and native features across Android, iOS, and Web environments. Determines the optimal interoperability strategy (FFI, Platform Channels, Platform Views, or JS Interop) and implements the necessary Dart and native code bindings while adhering to thread safety, WebAssembly (Wasm) compatibility, and modern build hook standards.
Instructions
1. Determine Integration Strategy (Decision Logic)
Evaluate the user's requirements using the following decision tree to select the correct integration path:
- Scenario A: Calling native C/C++ code.
- Action: Use
dart:ffiwith thepackage_ffitemplate and build hooks. - Exception: If accessing the Flutter Plugin API or requiring static linking on iOS, use the legacy
plugin_ffitemplate.
- Action: Use
- Scenario B: Calling OS-specific APIs (Java/Kotlin for Android, Swift/Obj-C for iOS).
- Action: Use Platform Channels (
MethodChannel) or thepigeonpackage for type-safe code generation.
- Action: Use Platform Channels (
- Scenario C: Embedding native UI components into the Flutter widget tree.
- Action: Use Platform Views (
AndroidView/AndroidViewSurfacefor Android,UiKitViewfor iOS).
- Action: Use Platform Views (
- Scenario D: Web integration and JavaScript APIs.
- Action: Use
package:webanddart:js_interop(Wasm-compatible). UseHtmlElementViewfor embedding web content.
- Action: Use