i want to show that some menu is premium, but somehow when text is wrapped, they doesn't lose its width. here is the example
Result:
Here is my code
return ListTile(
contentPadding: const EdgeInsets.fromLTRB(30, 0, 16, 0),
title: Row(
children: [
Flexible(
fit: FlexFit.loose,
child: Text(
test,
)),
Container(
alignment: Alignment.centerLeft,
padding:
const EdgeInsets.symmetric(horizontal: 15),
decoration:
cardDecoration(color: AppColors.greyCard),
child: Text(
'Premium',
style: h7(color: AppColors.mainGreen),
),
),
]
)
);
I do tried to make it with Text.rich, but I can't make it work better than this (sometimes they ddo look ugly
Here is my code:
return ListTile(
contentPadding: const EdgeInsets.fromLTRB(30, 0, 16, 0),
title: Row(
children: [
Expanded(
child: Text.rich(TextSpan(
text: test,
children: [
WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: Container(
margin: EdgeInsets.only(left: 8),
padding: const EdgeInsets.symmetric(
horizontal: 15),
decoration: cardDecoration(
color: Colors.grey[200]),
child: Text(
'Premium',
style: h7(color: AppColors.mainGreen),
),
),
)
])),
)
]
)
);