You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter中如何将TextButton.icon的文字放置在图标下方?

解决方案

默认TextButton.icon构造会自动将图标和label放在水平排列的Row中,无法直接修改排列方向,推荐直接使用普通TextButton构造,自定义child为纵向排列的Column即可实现需求,示例代码如下:

TextButton(
  onPressed: () => {},
  style: TextButton.styleFrom(
    // 可根据需求调整按钮内边距、最小尺寸等参数
    minimumSize: const Size(80, 80),
  ),
  child: Column(
    mainAxisSize: MainAxisSize.min, // 避免Column默认占用最大可用高度
    children: [
      Icon(
        Icons.add,
        color: Colors.white,
        size: 50,
      ),
      SizedBox(height: 4), // 图标和文字的间距,可自行调整
      Text(
        'Label',
        style: TextStyle(
          color: Colors.white,
        ),
      ),
    ],
  ),
)

如果需要保留TextButton.icon的调用形式,也可以自行封装对应的组件实现,上述方案代码更简洁,也更方便后续调整元素对齐、间距等样式。


内容的提问来源于stack exchange,提问作者meltdown_ultra

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.05 09:06:03