Snippet class
A one-line copyable code snippet with a shell symbol and copy button.
Renders text (or custom code content) in monospace, optionally
prefixed by symbol ($ by default). The trailing copy button writes
text to the clipboard, fires onCopy, and flips to a green check for
two seconds. Variants: soft (default), solid, outline.
const Snippet(text: 'flutter pub add jade_ui')
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- Snippet
Constructors
- Snippet({Key? key, required String text, String symbol = '\$', Widget? code, ColorRoleToken color = ColorRoleToken.default_, SnippetVariant variant = SnippetVariant.soft, RadiusToken? radius, VoidCallback? onCopy, bool hideCopyButton = false, bool hideSymbol = false})
-
Creates a snippet.
const
Properties
- code → Widget?
-
Custom widget replacing the plain-text rendering of text.
final
- color → ColorRoleToken
-
Color role the variant paints from.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hideCopyButton → bool
-
Hides the copy button.
final
- hideSymbol → bool
-
Hides the shell symbol prefix.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- onCopy → VoidCallback?
-
Called after a copy in addition to the clipboard write.
final
- radius → RadiusToken?
-
Corner radius token. Defaults to
SurfaceDefaults.radius, then RadiusToken.lg.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- symbol → String
-
Shell prompt symbol shown before the code.
final
- text → String
-
Text copied to the clipboard; also the default displayed content.
final
- variant → SnippetVariant
-
Visual style: soft (default), solid or outline.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< Snippet> -
Creates the mutable state for this widget at a given location in the tree.
override
-
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
-
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