MinimalCodeBlock class

A block of code, a command or a token in mono on the sunken well — an API key to paste, a webhook payload, a CLI line — with an optional caption band (label, usually the language or the file) and a copy action that puts code on the clipboard and confirms with a toast.

Long lines scroll sideways rather than wrapping (wrap: true wraps them); lineNumbers adds a faint number column, each number beside the first line of its own line of code however that line wraps. Pass onCopy to learn that it was copied; copyable: false drops the action.

MinimalCodeBlock('curl -X POST https://api.example.com/v1/orders', label: 'bash')
Inheritance

Constructors

MinimalCodeBlock(String code, {Key? key, String? label, bool copyable = true, VoidCallback? onCopy, String? copiedMessage, bool wrap = false, bool lineNumbers = false})
A block showing code.
const

Properties

code → String
The code, as it prints.
final
copiedMessage → String?
The toast the copy confirms with.
final
copyable → bool
Whether it offers a copy action.
final
hashCode → int
The hash code for this object.
no setterinherited
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
label → String?
The caption band's text: the language, a file name.
final
lineNumbers → bool
Whether it numbers its lines.
final
onCopy → VoidCallback?
Called after code reaches the clipboard.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
wrap → bool
Wrap long lines instead of scrolling them sideways.
final

Methods

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.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
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