Reputation: 881
Text.overflow doesn't apply on new lines :
Text(text,
maxLines: 3,
overflow: TextOverflow.ellipsis)
with 3 lines with the last being too long, overflow is working, but with 4 lines, the first 3 are displayed and no ellipsis is present :
line1
line2
line3
line4
result will be
line1
line2
line3
No ellipsis added, I was expecting
line1
line2
line3...
or
line1
line2
line3
...
Any way to do that ? I would prefer to keep the breaklines.
Upvotes: 0
Views: 46
Reputation: 7601
what you need is expandable_text:
ExpandableText(
longText,
expandText: '...',
collapseText: '',
maxLines: 3,
linkColor: Colors.black,
);
Upvotes: 1
Reputation: 1744
if your text contain breaklines or '\n' then it is not recognized as overflow. ellipsis will not appear if text doesn't overflow the width of the parent before interfering with breakline
try this and it will work
Text(" Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book , ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book , ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.",
maxLines: 3,
overflow: TextOverflow.ellipsis)
Upvotes: 0