Flutter › Flutter Plugin & Package Development

What is the basic folder structure of a typical Flutter plugin project, and how does it separate the shared Dart interface from each individual platform's own specific native implementation?

Beginner

Answer

A typical Flutter plugin project's folder structure includes a lib folder containing the shared Dart code that actually exposes your plugin's own public facing API, along with separate dedicated android and ios folders each containing that specific platform's own actual native implementation code, and this clear separation lets consumers of your plugin interact with just one single, consistent Dart interface while your plugin itself internally and transparently delegates the genuine underlying platform specific work to whichever native implementation is actually appropriate for the specific device the app happens to actually be currently running on.
my_plugin/
  lib/
    my_plugin.dart
  android/
    src/main/kotlin/
  ios/
    Classes/
Real-world example A plugin providing access to a device's specific battery level exposes just one single, clean getBatteryLevel method through its shared Dart interface, while internally properly delegating to entirely separate native Kotlin code on Android and separate native Swift code on iOS respectively.

Common follow-ups: What is a federated plugin, and how does it further separate these platform implementations into entirely distinct separate packages?;How do you properly test a plugin's own specific native platform code?