getErrorContent static method

String getErrorContent(
  1. String? content, {
  2. int maxLines = 3,
  3. int maxLength = 150,
})

Gets a formatted error content with line and character limits

@param content The error content to format @param maxLines The maximum number of lines (default: 3) @param maxLength The maximum length of the content (default: 150) @return The formatted error content

Implementation

static String getErrorContent(String? content,
    {int maxLines = 3, int maxLength = 150}) {
  if (isNullOrEmpty(content)) return '';
  if (content!.length > maxLength) return content.substring(0,maxLength);
  List<String> list = content.split('\n');
  list = list.sublist(0,min(list.length, maxLines));
  return list.join('\n');
}