如何在这样的文本末尾添加图标按钮?
我使用 Row 小部件但图标按钮不在正确的位置,它不在文本的末尾
这是我的代码:
Row(
children: [
Expanded(
child: Text(
'All about marketing, lead generation, content marketing and growth hacks',
style: const TextStyle(
fontSize: 12.0, fontWeight: FontWeight.w500),
),
),
IconButton(
icon: Icon(Icons.info),
iconSize: 12.0,
color: Palette.appbar,
onPressed: () {},
),
],
),
答案 0 :(得分:2)
将 RichText 与 TextSpan
和 WidgetSpan 一起使用。
WidgetSpan
允许添加您自己的小部件作为文本的一部分。
像这样:
RichText(
text: TextSpan(
children: <TextSpan>[
TextSpan(text: _text, style: _style),
WidgetSpan(
child: _child
)
],
),