shorten function
String
shorten(
- String text,
- int width, {
- int maxLines = 1,
- String initialIndent = '',
- String subsequentIndent = '',
- bool expandTabs = true,
- bool replaceWhitespace = true,
- bool fixSentenceEndings = false,
- bool breakLongWords = true,
- bool dropWhitespace = true,
- bool breakOnHyphens = true,
- int tabSize = 8,
- String placeholder = ' ...',
Collapse and truncate the given text to fit in the given width.
Implementation
String shorten(
String text,
int width, {
int maxLines = 1,
String initialIndent = '',
String subsequentIndent = '',
bool expandTabs = true,
bool replaceWhitespace = true,
bool fixSentenceEndings = false,
bool breakLongWords = true,
bool dropWhitespace = true,
bool breakOnHyphens = true,
int tabSize = 8,
String placeholder = ' ...',
}) {
return fill(text.split(spaceRe).join(' '),
width: width,
initialIndent: initialIndent,
subsequentIndent: subsequentIndent,
expandTabs: expandTabs,
replaceWhitespace: replaceWhitespace,
fixSentenceEndings: fixSentenceEndings,
breakLongWords: breakLongWords,
dropWhitespace: dropWhitespace,
breakOnHyphens: breakOnHyphens,
tabSize: tabSize,
maxLines: maxLines,
placeholder: placeholder);
}