A Journey with Flutter Native Plugin Development for iOS and Android
Building cross-platform plugins for iOS and Android from scratch. Code, pitfalls, real examples from a published plugin author.
Read on
Read on Medium โKey takeaways
- MethodChannel is enough for 80% of native plugin work.
- EventChannel handles streams from native to Dart.
- PlatformView is for actual native UI, not just data.
- iOS Swift bridge is finicky. Pin Xcode and Flutter versions in CI.
Frequently asked questions
MethodChannel vs PlatformView: which to use?
MethodChannel for one-off function calls and data exchange. PlatformView only when you need to embed an actual native UIView or Android View inside the Flutter widget tree.
How do I debug native plugin crashes?
On iOS, attach Xcode to the running iOS device or simulator and watch the console. On Android, run flutter logs while the app runs and look for native stack traces alongside Dart errors.
Should I write Swift or Objective-C for the iOS side?
Swift in 2024+. Objective-C is only worth it if you must support an old codebase. The Flutter plugin template defaults to Swift now.
How do I publish a native plugin?
Same flow as any pub.dev package: dart pub publish from the plugin root. Make sure your example app builds on both platforms before publishing or your pub score takes a hit.