Repository navigation
Transcript CodeBlock
A fenced code block: mono text on a surface2 well that scrolls sideways. It has no syntax colours; a host that wants them supplies its own MarkdownRenderer.
import 'package:agent_kit/agent_kit.dart';
Code block with a language: the standalone specimen CodeBlock(..., language: 'rust'). The language is not drawn; it appears only in the semantics label.
| Parameter | Type | Notes |
|---|---|---|
code |
String |
Required, positional. The code, without the fences. |
language |
String? |
The info string after the opening fence. Used only in the semantics label: Code, <language>. |
surface2 (well fill), radii.sm (corners), ink (text), typeScale.code (mono type, drawn through monoStyle, with calt and liga off).
Does not read the size class. The well fills the width it is given. Lines are not wrapped (softWrap: false); a wider line scrolls sideways inside the well.
-
Semantics(container: true, label: 'Code' or 'Code, <language>'). An empty or null language givesCode. - No keyboard handling for the sideways scroll beyond the default of
SingleChildScrollView.
- Gallery scene: Components. Specimen "Code block" in
TranscriptSpecimens(apps/gallery/lib/components/transcript.dart). - Golden:
apps/gallery/test/component_shots_test.dartwritescode_block, which takes the secondCodeBlockin the scene (index 1). The first is the copy inside the transcript list's assistant message. Light and dark. - Other tests:
packages/agent_kit/test/transcript/transcript_test.dart, "the default renderer draws prose and a code block" (line 58, expects oneCodeBlock). Transcript goldens inpackages/agent_kit/test/goldens/transcript_turn_*.pngandtranscript_states_*.png.
Generated from docs/components/transcript/CodeBlock.md. Edit the file there; changes made on the wiki are overwritten.
Guides
- Package layout and pinning
- agent_kit_core
- Backend mapping
- agent_kit and the gallery
- Icon and README assets
Component sheets
theme
status
transcript
- ActivityGroupView
- AssistantProse
- ChildQuestionRow
- CodeBlock
- DiffView
- ExecOutput
- FileEditRow
- PlanChecklist
- ReturnLine
- SystemLineView
- TranscriptList
- UserBubble
composer
chrome
context
history
outline
workspace
compositions
providers