truncate library
Text truncation library supporting predefined and custom truncation strategies
Classes
- CutStrategy
- CutStrategy cuts the string to the maximum length
- OmissionShortenStrategy
- OmissionShortenStrategy truncates text up to the maxLength using position and omission
- TruncateStrategy
- Abstract class for string truncation strategy
Enums
- TruncatePosition
- Truncation position
Constants
- DEFAULT_OMISSION → const String
- The default omission string is ellipsis
Functions
-
truncate(
String text, int maxLength, {String omission = DEFAULT_OMISSION, TruncatePosition position = TruncatePosition.end}) → String - Returns truncated string up to the maxLength at the selected position using the omission string
-
truncator(
String text, int maxLength, TruncateStrategy strategy) → String - Truncates text to maximum length using the selected strategy