I want to put three text widgets inside a row. Two text widgets can be long or short as it’s coming from API.
For example, there is a pickup location and a destination location which are separated by a "-"
.
I want that, it should not go on the next line, as all these three text widgets are now inside a row. Also if any of these text widgets got a single word then it should take minimum space. And if it got a long text from API then it will take up to half of the space maximum and the rest of the text is shown overflow.ellipsis
2
Answers
I found the solution. like this:-
here I use flexible to share free space equally for two text widgets if the text got a long text. and if one of those is not too long then it will take minimum space because of the flex fit set to loose. also, push the text widget to take maximum space and then start Overflow.ellipsis(...) here is used:-
and by this, I solved the problem I faced.
We can use the
RichText
widget along with TextSpan to style different parts of the text differently.Store data in 3 diff var.
Here is the implementation. You can also resize, restyle and customize everything yourself.