CodeSnippet constructor
const
CodeSnippet({})
Creates a CodeSnippet widget.
Displays syntax-highlighted code with automatic language detection, copy functionality, and optional custom actions.
Parameters:
code
(String, required): The source code to displaymode
(String, required): Programming language for highlightingconstraints
(BoxConstraints?, optional): Size constraints for display areaactions
(List
Example:
CodeSnippet(
code: 'print("Hello World")',
mode: 'dart',
constraints: BoxConstraints(maxHeight: 150),
);
Implementation
const CodeSnippet({
super.key,
this.constraints,
this.actions = const [],
required this.code,
required this.mode,
});