1
votes

I have in the database a string with multiple lines, like this:

"lorem ipsum \n\n another lines \n\n another line".

When I try to display the text in a text widget, only the first line gets shown, even if I have multiline set to null or a high value. I've read there is a way in Dart String to have a multiline text with ''' or """, but how to apply that to a string that I read in from the database?

Example:

Widget build(BuildContext context) {
  textFromDatabase = "lorem ipsum \n\n another line \n\n another line";
  return Text(textFromDatabase);
}

Will display only "lorem ipsum".

2
add codes with your problem statement for a better understanding. - OMi Shah

2 Answers

1
votes

Wrap your text widger under Expanded() as:

Expanded(
      child: Text(textFromDatabase, maxLines: 4,
        overflow: TextOverflow.ellipsis)
)
-1
votes

replace /n with \n in your String result