wrap function

List<String> wrap(
  1. String text, {
  2. int width = 70,
  3. String initialIndent = '',
  4. String subsequentIndent = '',
  5. bool expandTabs = true,
  6. bool replaceWhitespace = true,
  7. bool fixSentenceEndings = false,
  8. bool breakLongWords = true,
  9. bool dropWhitespace = true,
  10. bool breakOnHyphens = true,
  11. int tabSize = 8,
  12. int maxLines = -1,
  13. String placeholder = '...',
})

Wrap a single paragraph of text.

Implementation

List<String> wrap(
  String text, {
  int width = 70,
  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,
  int maxLines = -1,
  String placeholder = '...',
}) {
  var chunks = splitChunks(text,
      breakOnHyphens: breakLongWords,
      expandTabs: expandTabs,
      tabSize: tabSize,
      replaceWhitespace: replaceWhitespace);

  if (fixSentenceEndings) {
    fixEndings(chunks);
  }

  return wrapChunks(chunks,
      width: width,
      initialIndent: initialIndent,
      subsequentIndent: subsequentIndent,
      breakLongWords: breakLongWords,
      dropWhitespace: dropWhitespace,
      breakOnHyphens: breakOnHyphens,
      maxLines: maxLines,
      placeholder: placeholder);
}