StringWrapExtensions extension

Word wrap and grapheme-safe truncation.

on

Methods

preventOrphans({int minWrapChars = 4}) String

Available on String, provided by the StringWrapExtensions extension

Replaces a breaking space with a non-breaking space (\u{00A0}) wherever a line wrap at that space would strand a token shorter than minWrapChars on its own line.
truncateAtGrapheme(int maxGraphemes) String

Available on String, provided by the StringWrapExtensions extension

Truncates at grapheme boundary so no emoji or extended grapheme is cut.
wordWrap(int columnWidth) List<String>

Available on String, provided by the StringWrapExtensions extension

Wraps this string at columnWidth, breaking at word boundaries when possible.