format static method

String format(
  1. Object? value, {
  2. int? maxLength,
})

Renders value as the text shown in a row.

Strings are shown verbatim (without quotes); null shows as undefined to match TOML's absence of a null literal. If maxLength is non-null and the rendered text is longer, it is truncated with an ellipsis and a character count.

Implementation

static String format(Object? value, {int? maxLength}) {
  if (value == null) return 'undefined';
  final text = value.toString();
  if (maxLength == null || maxLength <= 0 || text.length <= maxLength) {
    return text;
  }
  return '${text.substring(0, maxLength)}… (${text.length} chars)';
}