# Platform Channels & Native Integration in Flutter

> Call Kotlin and Swift from Dart with MethodChannel, EventChannel and Pigeon, and embed native views. Free notes, key concepts, resources and a mini project.

Canonical: https://www.internhack.in/roadmaps/tracks/mobile/flutter-platform-channels
Last updated: 2026-11-28

Call Kotlin and Swift from Dart with MethodChannel, EventChannel and Pigeon, and embed native views.

Advanced · about 6 hours · difficulty 4/5

Learn first: [Structuring Real Flutter Apps](https://www.internhack.in/roadmaps/tracks/mobile/flutter-app-structure)

Flutter plugins on pub.dev cover most device features, but sometimes you need custom native code.

### Channels

- **MethodChannel**: call a named method on the native side and get a result asynchronously (`await channel.invokeMethod("getBattery")`).
- **EventChannel**: receive a stream of events from native code, such as sensor updates.
- **Pigeon**: generates type-safe Dart, Kotlin and Swift code from a Dart interface definition. Prefer it over hand-written string-based channels.

### Native views

`AndroidView` and `UiKitView` (platform views) embed native UI such as maps or ad views inside the widget tree. They cost some performance, so use them only when needed.

### FFI

`dart:ffi` calls C libraries directly, useful for performance-critical or existing C/C++ code.

### Good practice

- Wrap channels in a Dart class so the rest of the app never sees method names or raw maps.
- Handle `PlatformException` and missing implementations on each platform.
- If it could be reused, package it as a plugin.

**Good enough to move on:** you wrote a Pigeon-based API that returns device information from both Android and iOS.

## Key concepts

- **MethodChannel**
- **EventChannel**
- **Pigeon code generation**
- **Platform views**
- **dart:ffi**
- **Writing a plugin package**

## Mini project

Create a Flutter plugin that streams the device's step counter from native code to Dart and displays it live.

## Check yourself

Why is Pigeon safer than a hand-written MethodChannel?

## Free resources

- [Writing custom platform-specific code](https://docs.flutter.dev/platform-integration/platform-channels) (Flutter)
- [Pigeon package](https://pub.dev/packages/pigeon) (pub.dev)

Previous: [Structuring Real Flutter Apps](https://www.internhack.in/roadmaps/tracks/mobile/flutter-app-structure) · Next: [Android Components, Lifecycle & Gradle](https://www.internhack.in/roadmaps/tracks/mobile/android-fundamentals)

## More in Flutter & Dart in Depth

- [Widget Tree, BuildContext & Lifecycle](https://www.internhack.in/roadmaps/tracks/mobile/flutter-widgets)
- [Structuring Real Flutter Apps](https://www.internhack.in/roadmaps/tracks/mobile/flutter-app-structure)
- [Platform Channels & Native Integration in Flutter](https://www.internhack.in/roadmaps/tracks/mobile/flutter-platform-channels)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Mobile App Developer Roadmap](https://www.internhack.in/roadmaps/tracks/mobile)
