SecureCopyButton class

A widget that copies text securely to the clipboard on tap.

Optionally shows a snackbar with countdown and auto-clear notification.

SecureCopyButton(
  text: 'my-secret-api-key',
  expireAfter: Duration(seconds: 15),
  child: Icon(Icons.copy),
  onCopied: () => print('Copied!'),
)
Inheritance

Constructors

SecureCopyButton({required String text, required Widget child, Key? key, Duration? expireAfter, VoidCallback? onCopied, VoidCallback? onCleared, bool showSnackBar = true, Duration snackBarDuration = const Duration(seconds: 2), String? copiedMessage, String clearedMessage = 'Clipboard cleared', Widget feedbackBuilder(BuildContext, ClipboardCopyResult)?})
Creates a SecureCopyButton with the required text and child.
const

Properties

child Widget
The child widget displayed as the button content.
final
clearedMessage String
Message shown when the clipboard is cleared.
final
copiedMessage String?
Custom copied message. Use {seconds} as placeholder for the timer.
final
expireAfter Duration?
Optional duration override for auto-clear.
final
feedbackBuilder Widget Function(BuildContext, ClipboardCopyResult)?
Optional custom feedback builder instead of the default snackbar.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onCleared VoidCallback?
Called when the auto-clear timer fires.
final
onCopied VoidCallback?
Called after a successful copy.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
showSnackBar bool
Whether to show a snackbar after copying.
final
snackBarDuration Duration
Duration to display the snackbar.
final
text String
The text to copy to the clipboard.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<SecureCopyButton>
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