limit method

String limit(
  1. int count, {
  2. String suffix = '...',
})

Limits the string length to count and adds optional suffix.

Example:

print('Long Text'.limit(4)); // Long...

Implementation

String limit(int count, {String suffix = '...'}) =>
    length > count ? '${substring(0, count)}$suffix' : this;