I want to design a text widget that wraps automatically, and it uses an ellipsis when the text length exceeds the maximum.
The following code can achieve a similar effect.
Container(
color: Colors.red,
child: Text(
'DENTIFICATIONDENTIFICATIONDENTIFICATIONDENTIFICATIONDENTIFICATIONDENTIFICATIONDENTIFICATIONDENTIFICATIONDENTIFICATIONDENTIFICATIONDENTIFICATIONDENTIFICATIONDENTIFICATIONDENTIFICATIONDENTIFICATIONDENTIFICATIONDENTIFICATIONDENTIFICATIONDENTIFICATIONDENTIFICATION',
overflow: TextOverflow.ellipsis,
maxLines: 6,
),
),
But it must specify maxLines
, I don't want this, I need the widget to automatically set the maxLines
based on the size of parent.
How can I improve the code?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…