A common platform interface for the flutter_agent_kit plugin.

This package is not what app developers depend on directly — that's flutter_agent_kit itself. This package exists so platform implementations (today: flutter_agent_kit_android) can be developed and published independently, following Flutter's federated plugin architecture.

Usage

To implement a new platform package for flutter_agent_kit:

  1. Add flutter_agent_kit_platform_interface as a dependency.
  2. Create a class that extends (not implements) FlutterAgentKitPlatform, so new methods added here in a minor version bump come with a default UnimplementedError rather than breaking your implementation at compile time.
  3. Register it as the default instance in your platform package, following the federated plugin instructions.
class MyPlatformFlutterAgentKit extends FlutterAgentKitPlatform {
  static void registerWith() {
    FlutterAgentKitPlatform.instance = MyPlatformFlutterAgentKit();
  }

  @override
  Future<void> configureAgent(String agentId, AgentConfigMessage config) {
    // ...
  }

  // sendMessage, events, disposeAgent, registerToolHandler — see
  // FlutterAgentKitPlatform's own doc comments for exactly what each one
  // must do.
}

Why this contract is shaped the way it is

flutter_agent_kit's bridge is bidirectional, not just Dart-asks/host-answers: the native engine has to call into Dart mid-turn to run a tool and continue with its result. That's why this package is built on Pigeon rather than a hand-rolled MethodChannel — pigeons/messages.dart generates both a HostApi (Dart → native: configure, send) and a FlutterApi (native → Dart: invoke a tool) from one schema, type-safe on both sides. Turn output streams back over a plain EventChannel (events(agentId)) rather than through Pigeon, since Pigeon isn't the right shape for a long-lived stream.

Versioning note: this package and any platform implementation of it must be regenerated and version-bumped together, with a tight version constraint between them — Pigeon's own documentation warns that two different Pigeon versions generating each side of the same contract can cause runtime crashes, not just compile errors. See the header comment in pigeons/messages.dart for the schema itself.

See docs/adk-kotlin-capability-map.md at the repo root for what this contract needs to expose and why.

Libraries

flutter_agent_kit_platform_interface
The platform interface for flutter_agent_kit.