maxLength method
Cuts to max characters with "..." at the end. "Hello world".maxLength(max: 8) → "Hello..."
Implementation
String maxLength({required int max}) {
if (length <= max) return this;
if (max <= 3) return substring(0, max);
return "${substring(0, max - 3)}...";
}