formatMessagePreview static method

String formatMessagePreview(
  1. String message, {
  2. int maxLength = 30,
})

Formats a message for preview (truncates long messages)

Implementation

static String formatMessagePreview(String message, {int maxLength = 30}) {
  if (message.isEmpty) {
    return "No message";
  }

  // Replace newlines with spaces for cleaner preview
  String cleanMessage = message.replaceAll('\n', ' ');

  if (cleanMessage.length <= maxLength) {
    return cleanMessage;
  }

  return '${cleanMessage.substring(0, maxLength)}...';
}