flutter-native
Build type-safe native platform integrations using MethodChannels, EventChannels, and Pigeon. Use when communicating with Android/iOS native code, implementing federated plugins, or bridging platform-specific APIs.
Works with
---
name: flutter-native
description: Build type-safe native platform integrations using MethodChannels, EventChannels, and Pigeon. Use when communicating with Android/iOS native code, implementing federated plugins, or bridging platform-specific APIs.
license: MIT
---
# Native Platform Interoperability
Developing Flutter apps often requires direct communication with the underlying native platform (Android/iOS). This skill covers the standards for maintainable and type-safe interoperability.
## 1. MethodChannels (One-shot)
Use `MethodChannel` for standard request-response patterns between Dart and Native.
### Dart Standard
- Use a unique domain-style channel name.
- ALWAYS wrap calls in a try-catch for `PlatformException`.
```dart
static const _channel = MethodChannel('com.example.app/device_info');
Future<String?> getDeviceOS() async {
try {
return await _channel.invokeMethod<String>('getOS');
} on PlatformException catch (e) {
AppLogger.error('Failed to get OS', error: e);
return null;
}
}
```
## 2. EventChannels (Streams)
Use `EventChannel` for continuous data flow (e.g., sensor data, connectivity).
### Implementation
- Native side MUST handle `onListen` and `onCancel`.
- Dart side MUST dispose the subscription to prevent leaks.
## 3. Type Safety with Pigeon
For complex APIs, avoid manual string-based keys. Use **Pigeon** to generate type-safe interfaces.
## 4. Platform-Specific Directory Structure
Organize native code within the relevant feature if possible, or use a dedicated `plugins/` directory for shared logic.
## 5. Swift Package Manager (SPM) Defaults
*Introduced in Flutter 3.44*
- For iOS/macOS native integrations, SPM is the default package manager. It replaces CocoaPods entirely for new configurations.
- Declare Swift Packages directly in your plugin's `pubspec.yaml` using the `swift_packages` field, or configure them directly via Xcode workspaces (see [flutter-spm](file:///Users/dhruvanbhalara/Desktop/Github%20Projects/skills/skills/flutter/flutter-spm/SKILL.md)).
## 6. Platform View Overhaul
*Introduced in Flutter 3.44*
- Embedded native views (such as maps, web views, cameras) leverage an overhauled hybrid composition rendering pipeline to minimize dropped frames and eliminate UI compositing performance issues.
## 7. Federated Plugins
If the logic is reusable across multiple apps:
- Split implementation into `_platform_interface`, `_android`, `_ios`, and `_web` packages.
- Provide a single entry point for users.More Mobile skills
animation-vocabulary
emilkowalski/skills
Reverse-lookup glossary that turns a vague description of a web animation or motion effect into its exact term ("the bouncy thing when a popover opens" → Pop in; "the iOS rubber-band scroll" → Rubber-banding). Use when the user asks "what's it called when…", or describes a motion effect without knowing its name and wants the right word to prompt an AI or designer with. For naming an effect, not designing or building one.
xcode-project-setup
firebase/agent-skills
Safely modifies Xcode projects (.pbxproj) to add Swift Packages and link files. Use this skill whenever an iOS project needs dependencies installed (e.g. Firebase, Alamofire).
cross-border-ecommerce
nexscope-ai/ecommerce-skills
Cross-border e-commerce expansion advisor. Scores target markets on 8 weighted dimensions (market size, ecommerce penetration, competition, regulatory complexity, logistics infrastructure, payment ecosystem, cultural distance, IP protection), compares 5 fulfillment models with cost and transit data, provides country-by-country tax/duty compliance guides (EU VAT/IOSS, UK VAT, US sales tax, CA GST, AU GST, JP consumption tax), maps local payment preferences by market, and builds a phased expansion roadmap. No API key required.

