Search code examples
textflutter

Meaning of Paragraph in Flutter classes


There are several classes and methods in Flutter that have "Paragraph" in the name. Examples:

What is the meaning of paragraph here? Usually I think of a paragraph of text as a few of sentences with no new line characters. Can a Flutter paragraph contain multiple new lines?

The documentation isn't clear:

Paragraph class

A paragraph of text.


Solution

  • A Flutter Paragraph can contain more that one newline character. This can be demonstrated by using the following text string in a ParagraphBuilder or a TextPainter, which creates a single Paragraph in the Flutter sense of the word.

    final text = 'My text line.\nThis line is longer than the last.\nAnother line.';
    

    See here and here.

    See also