Platform Boundaries

Flutter keeps UI and business logic shared. Platform behavior still needs explicit boundaries.

Boundary Decision Table

NeedStart withUse when
Existing device APIPub package/pluginA maintained plugin supports every target you need
Small native API callMethodChannelYou control app code and need a few async method calls
Typed native API surfacePigeonChannel calls are growing or need generated host/Dart bindings
Native C-compatible libraryFFIYou need direct native library calls, especially desktop/mobile
Native UI inside FlutterPlatform viewsYou must embed a native map, web view, camera, or platform component
Web browser APIJS interopFlutter web needs a browser API not exposed by a package
Existing native appAdd-to-appFlutter is one module inside Android/iOS/macOS, not the whole app

Target Languages

Platform-channel implementation languages follow the target:

TargetTypical implementation language
AndroidKotlin or Java
iOSSwift or Objective-C
WindowsC++
macOSObjective-C or Swift depending on plugin shape
LinuxC
WebJavaScript interop, not normal platform channels

Practical Rules

  1. Prefer a high-quality plugin before writing platform code.
  2. Verify platform support in the plugin’s pub.dev metadata and docs.
  3. Add the platform test before adding more platform APIs.
  4. Keep channel names, method names, and codecs stable once released.
  5. Never assume mobile plugin support means desktop or web support.

Gotcha: Adding a plugin with native code often needs a full app restart. Hot reload is not enough to prove the new platform code is loaded.