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

如何用Row和Column组件在Card容器内实现L型布局

Flutter 实现指定Card布局

可以通过Stack结合Positioned组件来实现你需要的布局,完整代码示例如下:

SizedBox(
  height: 300, // 控制Card的总高度
  child: Card(
    elevation: 4,
    child: Stack(
      children: [
        // 蓝色区域:全高,固定宽度
        const Positioned(
          left: 0,
          top: 0,
          bottom: 0,
          width: 100, // 可自行调整固定宽度
          child: ColoredBox(color: Colors.blue),
        ),
        // 绿色区域:固定高度,剩余宽度
        const Positioned(
          left: 100,
          top: 0,
          right: 0,
          height: 80, // 可自行调整固定高度
          child: ColoredBox(color: Colors.green),
        ),
        // 紫色区域:Card剩余高度,固定宽度
        Positioned(
          left: 0,
          top: 80, // 与绿色区域高度对齐
          bottom: 0,
          width: 100,
          child: const ColoredBox(color: Colors.purple),
        ),
        // 粉色区域:Card剩余高度,剩余宽度
        Positioned(
          left: 100,
          top: 80,
          right: 0,
          bottom: 0,
          child: const ColoredBox(color: Colors.pink),
        ),
      ],
    ),
  ),
)

说明

  • 可根据需求修改SizedBox的height、各区域的固定宽高数值
  • 示例中用ColoredBox占位,实际可替换为业务所需的子组件
  • Positioned通过精准定位完美匹配你提出的布局尺寸规则

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.09 20:40:10