TCopyButton class
A button that copies text to the clipboard with animated state feedback.
TCopyButton automatically updates its icon and tooltip upon being clicked,
displaying a confirmation checkmark for a configurable duration (default: 2s),
and optionally triggering a TToastService toast notification.
Basic Usage
// Icon-only copy button
TCopyButton(text: 'https://example.com/share')
// Button with label and toast notification
TCopyButton(
text: apiKey,
label: 'Copy Key',
copiedLabel: 'Copied!',
showToast: true,
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- TCopyButton
- Available extensions
Constructors
- TCopyButton({Key? key, required String text, String? label, String? copiedLabel, dynamic icon, dynamic copiedIcon, TButtonType type = TButtonType.softText, TButtonSize size = TButtonSize.xs, Color? color, Color? copiedColor, String? tooltip = 'Copy to clipboard', String? copiedTooltip = 'Copied!', bool showToast = false, String toastMessage = 'Copied to clipboard', Duration resetDuration = const Duration(seconds: 2), VoidCallback? onCopied})
-
Creates a copy button.
const
Properties
- color → Color?
-
Primary color for the button.
final
- copiedColor → Color?
-
Accent color used when in the copied state. Defaults to ColorScheme.primary.
final
- copiedIcon → dynamic
-
Success icon displayed after copying. Defaults to Icons.check_rounded.
final
- copiedLabel → String?
-
Optional label text displayed while in the copied state.
final
- copiedTooltip → String?
-
Tooltip message while in the copied state. Defaults to 'Copied!'.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- icon → dynamic
-
Normal icon displayed before copying. Defaults to Icons.copy_rounded.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- label → String?
-
Optional label text displayed on the button.
final
- onCopied → VoidCallback?
-
Optional callback invoked when the text is copied.
final
- resetDuration → Duration
-
Duration to hold the copied state before reverting to the default state.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- showToast → bool
-
Whether to show a success toast notification via TToastService.
final
- size → TButtonSize
-
Button sizing metrics. Defaults to TButtonSize.xs.
final
- text → String
-
The text content to be copied to the clipboard.
final
- toastMessage → String
-
Toast message displayed if showToast is true.
final
- tooltip → String?
-
Tooltip message before copying. Defaults to 'Copy to clipboard'.
final
- type → TButtonType
-
Visual button type. Defaults to TButtonType.softText.
final
Methods
-
box(
{double minW = 0.0, double minH = 0.0, double maxW = double.infinity, double maxH = double.infinity}) → Widget -
Available on Widget, provided by the WidgetX extension
Wraps this widget in a ConstrainedBox to apply layout constraints. -
center(
{bool when = true}) → Widget -
Available on Widget, provided by the WidgetX extension
Wraps this widget in a Center widget. -
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< TCopyButton> -
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
-
expanded(
{int flex = 1}) → Widget -
Available on Widget, provided by the WidgetX extension
Wraps this widget in an Expanded widget. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
padding(
[double left = 0.0, double top = 0.0, double right = 0.0, double bottom = 0.0]) → Widget -
Available on Widget, provided by the WidgetX extension
Wraps this widget in a Padding with flexible edge control. -
paddingSymmetric(
{double h = 0.0, double v = 0.0}) → Widget -
Available on Widget, provided by the WidgetX extension
Wraps this widget in a Padding with symmetric horizontal and vertical spacing. -
size(
{double? w, double? h}) → Widget -
Available on Widget, provided by the WidgetX extension
Wraps this widget in a SizedBox to apply fixed width and/or height. -
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
-
visible(
bool visible, {bool maintainState = false}) → Widget -
Available on Widget, provided by the WidgetX extension
Wraps this widget in a Visibility widget. -
when(
bool condition) → Widget -
Available on Widget, provided by the WidgetX extension
Returns this widget ifconditionis true, otherwise returns SizedBox.shrink(). Usage: Text('Hello').when(isVisible)
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited