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

Flutter中Column内Text用textTheme溢出,Expanded/ListView无效?

问题根源与解决方案

错误原因

你在CustomTheme的displayLarge样式里犯了一个关键错误:TextStyle的height属性是行高与字体大小的倍数,不是绝对像素值。

你设置了height:64,这会让文本的行高变成 fontSize(57) × 64 = 3648px——这个高度远大于手机屏幕的常规高度(一般在1000px以内),所以不管你用Column还是ListView,文本自身的高度已经超出了屏幕范围,必然会触发溢出错误。

修复步骤

修改CustomTheme中displayLarge的height参数,改成合理的倍数(比如1.2~1.5,或者直接移除该参数使用默认值):

class CustomTheme {
  static getTheme() {
    return ThemeData(
        textTheme: GoogleFonts.interTextTheme(
          const TextTheme(
            displayLarge:
                TextStyle(fontSize: 57, letterSpacing: 0.25, height: 1.2), // 修正height为合理倍数
          ),
        ),
        primaryColor: AppConstants.gold,
        useMaterial3: true);
  }
}

验证修复

修改后,文本的行高会变成57×1.2=68.4px,这个高度符合正常排版逻辑,再使用Column或ListView就不会出现溢出问题了。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.11 04:42:48