codeBuilder property
Custom widget builder for rendering code blocks.
This builder is called for each fenced code block in the markdown, receiving:
code: The code content as a stringlanguage: The language identifier (e.g., 'dart', 'javascript'), or null if not specified
If not provided, code blocks are rendered using the default builder which
includes syntax highlighting via flutter_highlight.
Example:
codeBuilder: (code, language) {
return Container(
padding: EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.black87,
borderRadius: BorderRadius.circular(8),
),
child: SelectableText(
code,
style: TextStyle(
fontFamily: 'Courier New',
color: Colors.white,
),
),
);
}
Implementation
final Widget Function(String code, String? language)? codeBuilder;