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

Flutter中Row内Text与IconButton垂直对齐失效问题求助

Flutter Row组件内元素垂直对齐异常问题

我无法让Row组件中的Text、IconButton和Text实现垂直对齐,已尝试设置crossAxisAlignment: CrossAxisAlignment.center但问题仍未解决。对应的Row代码如下:

Row(
  crossAxisAlignment: CrossAxisAlignment.center,
  children: [
    Text(DateFormat('dd-MM-yyyy').format(wd.date!), style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16), textAlign: TextAlign.left),
    IconButton(
        iconSize: 17,
        padding: EdgeInsets.all(3),
        onPressed: wd.resetRequested ?? false ? null : () async {
          showConfirm(context, wd, reloadMonthCallback);
        },
        icon: Icon(Icons.delete)
    ),
    Text("${wd.totalHourCount.toStringAsFixed(2)}h", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 13), textAlign: TextAlign.right)
  ],
),

当前显示效果(垂直对齐失效):
垂直对齐失效效果

注:基于Flutter Web开发。

更新:尝试使用Expanded包裹元素后,桌面端显示恢复正常,但Android端PWA仍存在轻微对齐偏差:
Android PWA对齐问题效果


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.20 12:12:10