Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Line Breaks in Long Text Flutter

Tags:

How can I create line breaks within a long Text widget?

For example, I am creating a biographical page about myself. And I have three paragraphs I want to be able to display. But currently, I am outputting those paragraphs in one big Text Widget and the output does not have line breaks to differentiate the paragraphs. How can I do that?

like image 746
HDiamond Avatar asked Aug 07 '18 18:08

HDiamond


People also ask

How do you do a line break in text in Flutter?

This can be achieved by adding \n into your text widget as below. Here is the code from main. dart file to achieve this.


1 Answers

declare your text like so:

final String someText = 
"stuff for the 1st paragraph\n\n"
"stuff for the 2nd paragraph\n\n"
"stuff for the 3rd paragraph\n\n";

and then you can just render it inside of a Text widget like you normally would.

like image 179
blaneyneil Avatar answered Sep 19 '22 07:09

blaneyneil