Without specifying the maximum number of lines, the text is truncated after 1 line. With a larger value than the size of the parent allows, the text goes beyond the parent and there are no errors.
@override
Widget build(BuildContext context) {
return MaterialApp(
home: SafeArea(
child: Material(
child: Column(
children: [
Container(
color: Colors.black12,
height: 100,
child: Text(
'dsf sdf ds fs dfsdfdf iuh gyj gy y'
' guygiukjh uiygihjo; rdtfyguhijok rftyguhij yguhij'
'dsf sdf ds fs dfsdfdf iuh gyj gy y'
' guygiukjh uiygihjo; rdtfyguhijok rftyguhij yguhij'
'dsf sdf ds fs dfsdfdf iuh gyj gy y'
' guygiukjh uiygihjo; rdtfyguhijok rftyguhij yguhij'
'dsf sdf ds fs dfsdfdf iuh gyj gy y'
' guygiukjh uiygihjo; rdtfyguhijok rftyguhij yguhij'
'dsf sdf ds fs dfsdfdf iuh gyj gy y'
' guygiukjh uiygihjo; rdtfyguhijok rftyguhij yguhij',
overflow: TextOverflow.ellipsis,
maxLines: 122,
),
),
],
),
),
),
);
}
softWrap does not affect in any way, and also does not help to wrap Flexible and Expanded.
5
Answers
You need to wrap your SingleChildScrollView in a Text widget and you will get what you are looking for.
just remove
height: 100,
and it will be fixed.Remove following two lines from your code.
Edited
And add
textAlign
asjustify
replace TextOverflow.ellipsis with :
overflow: TextOverflow.visible,
oroverflow: TextOverflow.clip,
maxLines
does give this weird behaviour.Since you have hardcoded height, just go with hardcoding maxLines that would fit that height. then as suggested by some answers, wrap your text with
Expanded
. as you wanted, this will show overflow warning ifmaxLines
don’t fit in given height.