printParagraph static method

Future<bool> printParagraph(
  1. String text, {
  2. int lineWidth = 48,
  3. String fontFamily = 'Siemreap',
  4. double fontSize = 20,
  5. FontWeight fontWeight = FontWeight.normal,
  6. bool breakWords = false,
})

Print a paragraph of text with automatic word wrapping.

Takes a long text and wraps it to fit the printer width.

  • text: The paragraph text to print
  • lineWidth: Maximum width of each line in characters
  • fontFamily: Font family to use
  • fontSize: Font size in points
  • fontWeight: Font weight (normal, bold, etc.)
  • breakWords: Whether to break words that are longer than line width

Returns true if printing was successful.

Implementation

static Future<bool> printParagraph(
  String text, {
  int lineWidth = 48,
  String fontFamily = 'Siemreap',
  double fontSize = 20,
  FontWeight fontWeight = FontWeight.normal,
  bool breakWords = false,
}) async {
  // Wrap the text into lines
  final lines =
      TextFormatter.wrapText(text, lineWidth, breakWords: breakWords);

  // Print the wrapped lines
  return await printLines(
    lines,
    fontFamily: fontFamily,
    fontSize: fontSize,
    fontWeight: fontWeight,
  );
}