copyButton method

DefineMTileModifier copyButton({
  1. String? buttonText,
  2. String? copyContent,
  3. double? width,
  4. double? height,
  5. double? radius,
  6. VoidCallback? onCopy,
})

Implementation

DefineMTileModifier copyButton({
  String? buttonText,
  String? copyContent,
  double? width,
  double? height,
  double? radius,
  VoidCallback? onCopy,
}) {
  final heightResult = height ?? 32.px;
  final DefineMTileModifier newModifierValue = this.copyWith(
    valueWidgetRight: MButton(
      text: buttonText ?? "Copy",
      fontSize: 16.px,
      width: width,
      height: heightResult,
      maxHeight: heightResult,
      padding: width == null
          ? EdgeInsets.symmetric(horizontal: 10.px)
          : EdgeInsets.zero,
      borderRadius: BorderRadius.all(Radius.circular(radius ?? 16.px)),
      onTap: () async {
        await Clipboard.setData(ClipboardData(text: copyContent ?? ""));
        if (onCopy != null) onCopy();
      },
    ),
  );
  return newModifierValue;
}