flutter_agent_kit 0.0.1
flutter_agent_kit: ^0.0.1 copied to clipboard
Flutter bindings for Google's Agent Development Kit (ADK) for Kotlin — build on-device and cloud AI agents with tool calling, from Dart.
Flutter bindings for Google's Agent Development Kit (ADK) for Kotlin — build on-device and cloud AI agents with tool calling, from pure Dart.
Status: Android-only v1. Not yet published to pub.dev.
Features #
- Streaming chat, token by token, against a real model — not a mock.
- Tools defined entirely in Dart — a name, a JSON-Schema parameter map, and a callback. No native code required.
- Two model backends:
AgentModelConfig.cloud()(Firebase AI-backed Gemini) orAgentModelConfig.onDevice()(LiteRT-LM, offline). Both support tool calling identically, so switching backends never silently breaks a tool. - Session persistence as a single config flag (
AgentSessionConfig.memory()vs.persistent()) — no separate session-service concept to learn.
See docs/adk-kotlin-capability-map.md for exactly what ADK-Kotlin can and can't do, and why this package is shaped the way it is.
Getting started #
Add the dependency:
dependencies:
flutter_agent_kit: ^0.0.1
If you're using AgentModelConfig.cloud(), your app needs its own Firebase project (this package can't supply one for you):
- Create a project at console.firebase.google.com and register your Android app.
- Download
google-services.jsonintoandroid/app/. - In the project's console, go to AI Services → AI Logic, click Get started, and choose Gemini Developer API (free tier).
Android requires compileSdk 37, minSdk 26, and a jvmToolchain(17) — these come from ADK-Kotlin's and Firebase's own floors, not this package. See flutter_agent_kit_android's README for the full setup and troubleshooting notes.
Usage #
import 'dart:math';
import 'package:flutter_agent_kit/flutter_agent_kit.dart';
final agent = Agent(
instructions: 'You are a helpful assistant. Use tools when they help.',
model: const AgentModelConfig.cloud(),
tools: [
AgentTool(
name: 'roll_dice',
description: 'Rolls a standard six-sided die and returns the result.',
parametersSchema: const {'type': 'object', 'properties': {}},
execute: (args) async => {'result': Random().nextInt(6) + 1},
),
],
);
await for (final event in agent.send('Roll a die for me')) {
switch (event) {
case AgentTextDelta(:final text):
print('...$text'); // partial, streamed chunk
case AgentFinalResponse(:final text):
print('Final: $text');
case AgentToolCall(:final toolName):
print('Calling $toolName...');
case AgentError(:final message):
print('Error: $message');
}
}
await agent.dispose(); // when the agent is no longer needed
To remember the conversation across app restarts, pass session: const AgentSessionConfig.persistent() — everything else about agent.send(...) stays the same.
Additional information #
flutter_agent_kit/exampleis a full working chat app (streaming, the tool round-trip, a persistence toggle) — the fastest way to see this package actually run.docs/at the repo root has the full research trail: what ADK-Kotlin supports, how it compares to Apple's on-device framework, and the implementation plan this package was built against.flutter_agent_kit_platform_interfaceis the platform contract this package talks to — only relevant if you're implementing support for a new platform.