# 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.

- **Type:** Skill
- **Install:** `agentstack add skill-dhruvanbhalara-skills-flutter-native`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [dhruvanbhalara](https://agentstack.voostack.com/s/dhruvanbhalara)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [dhruvanbhalara](https://github.com/dhruvanbhalara)
- **Source:** https://github.com/dhruvanbhalara/skills/tree/main/skills/flutter/flutter-native
- **Website:** https://dhruvanbhalara.github.io/skills/

## Install

```sh
agentstack add skill-dhruvanbhalara-skills-flutter-native
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# 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 getDeviceOS() async {
  try {
    return await _channel.invokeMethod('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.

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [dhruvanbhalara](https://github.com/dhruvanbhalara)
- **Source:** [dhruvanbhalara/skills](https://github.com/dhruvanbhalara/skills)
- **License:** MIT
- **Homepage:** https://dhruvanbhalara.github.io/skills/

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-dhruvanbhalara-skills-flutter-native
- Seller: https://agentstack.voostack.com/s/dhruvanbhalara
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
