[英]How to show Icon in the end of text in flutter?
即使文本是省略號,我也想在文本末尾顯示圖標。
這是我的代碼
Text.rich(
TextSpan(
children: [
const TextSpan(
text:
"Singapore & Shenzhen & Guangzhou & Beijing ni hao hao",
style: TextStyle(
fontSize: 28,
fontWeight: FontWeight.bold,
color: Colors.white),
),
WidgetSpan(
child: Container(
margin: const EdgeInsets.only(left: 7),
child: SvgPicture.asset(
R.triangle_down_fill,
package: R.package,
width: 18,
height: 18,
),
),
)
],
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
softWrap: true,
)
它在第一種情況下效果很好,但在第二種情況下效果不佳,圖標被文本刪除。
所以我該怎么做?
您可以使用Wrap
小部件包裝您的小部件
Wrap(
children: [Text.rich(
TextSpan(
children: [
const TextSpan(
text:
"Singapore & Shenzhen & Guangzhou & Beijing ni hao hao",
style: TextStyle(
fontSize: 28,
fontWeight: FontWeight.bold,
color: Colors.white),
),
WidgetSpan(
child: Container(
margin: const EdgeInsets.only(left: 7),
child: SvgPicture.asset(
R.triangle_down_fill,
package: R.package,
width: 18,
height: 18,
),
),
)
],
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
softWrap: true,
),
Icon(Icons.arrow_drop_down_circle)
],
),
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.