Dart Chat App
This example focuses on how agentos-sdk-dart and chatkit_dart fit together.
If you are using an AI coding tool, treat this page as reference truth for ChatKit integration structure.
If the generated Flutter chat integration disagrees with the docs, compare it against the minimal skeleton here first.
Recommended prompt
text
Use the AgentOS Dart chat app example as the reference shape and generate a ChatKit integration in my Flutter project that stays as close to that structure as possible.
Requirements:
- Use AgentOsConfig for connection info
- Use ChatKitRuntime for shared session management and background preconnect
- Use AgentSidebar as the chat UI entry point
- Preserve host-page control over config save, logout, and bridge decisions
- Do not blur the responsibilities of chatkit_dart and agentos_sdkRecommended source files
- chatkit_dart/example/lib/main.dart
- chatkit_dart/example/lib/ui/agent_sidebar_demo_page.dart
- chatkit_dart/README.md
Typical structure
A minimal Flutter chat app usually includes:
AgentOsConfigforbaseUrl,bundleId, and other connection infoChatKitRuntimefor shared session management and background preconnectAgentSidebaras the chat UI entry point- a host page that owns config persistence, logout, and bridge decisions
Minimal integration skeleton
dart
late final ChatKitRuntime runtime;
@override
void initState() {
super.initState();
runtime = ChatKitRuntime(config: config);
unawaited(runtime.start());
}
@override
Widget build(BuildContext context) {
return AgentSidebar(
runtime: runtime,
config: config,
onConfigSaved: (next) async {
runtime.updateConfig(next);
},
onLogout: () async {
await runtime.stop();
},
);
}Follow-up suggestions
- If you want custom copy, use
AgentSidebarStrings - If you want to inject business tools, pass
toolintoAgentSidebar - If you need system-event handling, make
onSystemCallAppthe central decision point
AI mistakes to watch for
- Treating ChatKit as the capability-layer SDK and skipping
agentos_sdk - Removing host ownership over config persistence and logout
- Omitting
ChatKitRuntime, which weakens shared message flow and background preconnect - Auto-executing system-call bridging without any trust or policy checks
Manual verification checklist
- Does the structure still look like
AgentOsConfig -> ChatKitRuntime -> AgentSidebar -> host decision point? - Does it preserve host callbacks such as
onConfigSavedandonLogout? - Does it leave explicit positions for
toolinjection andonSystemCallApp?
