I want to create a widget (blue background)as the picture depict:
- If the text count is not too much ( will not exceed the screen edge)
, it will layout as a Row widget - If the text count is too much ,all the text content is too long ,
and it will exceed the screen edge if all the text are lay out. So
it will only layout the Text1 and Text2 ,and add a "…" at last ,
ignore the other text.
How to achieve this in Flutter ?(the left and right widget’s size is not fixed)
2
Answers
For Text Widgets you can use TextSpan wrapped inside a RichText:
If the widget are mixed, you can wrap the widgets inside a row with Flexible.
Results:
I used tuple but you can avoid it.
the measure widget method from this answer