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.


PaymentCopyButton( value: '8808 1234 5678 9012', onCopy: _copyGalleryValue, );Variants
Section titled “Variants”Variants: idle, pending, copied, failed.
Which variant when
Section titled “Which variant when”| 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.
States
Section titled “States”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 and don’t
Section titled “Do and don’t”Do: Supply the exact reference and return whether host copying succeeded.
Don’t: Access the platform clipboard from the kit.
Content guidelines
Section titled “Content guidelines”Identify the value being copied. Report failure beside that value instead of showing a success message before the host finishes.
Accessibility
Section titled “Accessibility”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.
| Parameter | Type | Default | Description |
|---|---|---|---|
value:required | String | — | Synthetic or host-supplied value to copy. |
onCopy:required | Future<bool> Function(String value) | — | Host copy implementation; exceptions are reported as failure. |
tooltip: | String? | — | Spoken label; defaults to the localized copy action. |
In the example app
Section titled “In the example app”

PaymentCopyButton
class PaymentCopyButton extends StatefulWidget · lib/src/controls/actions.dart
Host-owned copying with a temporary check and persistent inline failure.
| Parameter | Type | Default | Description |
|---|---|---|---|
value:required | String | — | Synthetic or host-supplied value to copy. |
onCopy:required | Future<bool> Function(String value) | — | Host copy implementation; exceptions are reported as failure. |
tooltip: | String? | — | Spoken label; defaults to the localized copy action. |