Skip to content
Get started
Menu
Get started

Copy button

Your onCopy callback does the copying and returns whether it worked. Success shows a check and live Copied announcement for 1500 ms. Failure shows Copy failed beneath the icon until the next attempt. Pending presses cannot duplicate the host call. Value changes invalidate stale results. There are no additional variants.

Copy actions for payment references, including a failed copy with a retry action.Copy actions for payment references, including a failed copy with a retry action.
Copy button
example/lib/screens/gallery_selection.dart
PaymentCopyButton(
value: '8808 1234 5678 9012',
onCopy: _copyGalleryValue,
);

Variants: idle, pending, copied, failed.

Situation Variant / composition Payment example
Transaction reference idle Supply the exact reference and return whether host copying succeeded.

Use Icon button for actions without copy feedback.

The glyph cross-fades over 150 ms; instant under reduced motion.

onCopy returns whether copying succeeded. The button blocks repeat presses while waiting, announces success, and keeps a failure message visible until the next attempt.

Layout. The button keeps its 48 dp box in every state. A failed copy shows an error glyph in the danger tone and a persistent “Copy failed” label under the button’s end edge, laid over the content below so nothing moves; the next press or a new value clears it.

Do: Supply the exact reference and return whether host copying succeeded.

Don’t: Access the platform clipboard from the kit.

Identify the value being copied. Report failure beside that value instead of showing a success message before the host finishes.

Targets are at least 48 dp. Tooltips name icon actions. Links announce their role and external destinations. Copy feedback uses a live region and a check rather than color alone.

PaymentCopyButton

class PaymentCopyButton extends StatefulWidget · lib/src/controls/actions.dart

Host-owned copying with a temporary check and persistent inline failure.

ParameterTypeDefaultDescription
value:requiredString—Synthetic or host-supplied value to copy.
onCopy:requiredFuture<bool> Function(String value)—Host copy implementation; exceptions are reported as failure.
tooltip:String?—Spoken label; defaults to the localized copy action.
Example transaction detail screen with synthetic dataExample transaction detail screen with synthetic data
Example: transaction detail

PaymentCopyButton

class PaymentCopyButton extends StatefulWidget · lib/src/controls/actions.dart

Host-owned copying with a temporary check and persistent inline failure.

ParameterTypeDefaultDescription
value:requiredString—Synthetic or host-supplied value to copy.
onCopy:requiredFuture<bool> Function(String value)—Host copy implementation; exceptions are reported as failure.
tooltip:String?—Spoken label; defaults to the localized copy action.