CodeBlockWidget class

A widget that displays code with optional syntax highlighting.

Syntax highlighting requires a CodeHighlighter plugin (e.g. the HyperHighlighter from hyper_render_highlight). Without a plugin the code is rendered as plain monospace text, which keeps the core package free of heavy highlight.js dependencies.

Inheritance
Available extensions

Constructors

CodeBlockWidget({Key? key, required String code, String? language, CodeTheme theme = CodeTheme.vs2015, EdgeInsets padding = const EdgeInsets.all(16), BorderRadius borderRadius = const BorderRadius.all(Radius.circular(8)), bool showLineNumbers = false, bool showCopyButton = true, TextStyle? textStyle, CodeHighlighter? highlighter})
const

Properties

borderRadius BorderRadius
Border radius of the code block container.
final
code String
The source code to display.
final
hashCode int
The hash code for this object.
no setterinherited
highlighter CodeHighlighter?
Syntax-highlighting plugin.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
language String?
Programming language hint (e.g. 'dart', 'javascript').
final
padding EdgeInsets
Padding inside the code block.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
showCopyButton bool
Whether to show a copy-to-clipboard button.
final
showLineNumbers bool
Whether to show line numbers in the gutter.
final
textStyle TextStyle?
Text style override applied to the code text.
final
theme CodeTheme
Visual theme — used to pick background colour and passed to highlighter.
final

Methods

bounce({Duration duration = const Duration(milliseconds: 1000), int? iterationCount}) Widget

Available on Widget, provided by the HyperAnimationExtension extension

Apply a bounce animation
build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
fadeIn({Duration duration = const Duration(milliseconds: 300), Duration delay = Duration.zero, Curve curve = Curves.ease}) Widget

Available on Widget, provided by the HyperAnimationExtension extension

Apply a fade in animation
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pulse({Duration duration = const Duration(milliseconds: 1000), int? iterationCount}) Widget

Available on Widget, provided by the HyperAnimationExtension extension

Apply a pulse animation
slideInLeft({Duration duration = const Duration(milliseconds: 300), Duration delay = Duration.zero, Curve curve = Curves.ease}) Widget

Available on Widget, provided by the HyperAnimationExtension extension

Apply a slide in from left animation
spin({Duration duration = const Duration(milliseconds: 1000), int? iterationCount}) Widget

Available on Widget, provided by the HyperAnimationExtension extension

Apply a spin animation
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited