import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import 'haptics.dart';

/// Copies [text] to the system clipboard and shows a SnackBar.
Future<void> copyToClipboard(
  BuildContext context,
  String text, {
  String successMessage = 'In Zwischenablage kopiert',
}) async {
  await Clipboard.setData(ClipboardData(text: text));
  Haptics.selection();
  if (!context.mounted) return;
  ScaffoldMessenger.of(context).showSnackBar(
    SnackBar(
      content: Text(successMessage),
      duration: const Duration(seconds: 2),
    ),
  );
}
