# RenderFlex 子项具有非零弹性，但传入的高度约束是无界的

- **ID:** `flutter/renderflex-vertical-viewport`
- **领域:** flutter
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 95%

## 根因

带有 Expanded 子项的 Column 或 Flex 小部件被放置在未提供有界高度约束的可滚动视图（例如 ListView、SingleChildScrollView）内。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Flutter 3.10.0 | active | — | — |
| Dart 3.0.0 | active | — | — |

## 解决方案

1. ```
   Wrap the Column inside an IntrinsicHeight widget to provide a bounded constraint. Example: IntrinsicHeight(child: Column(children: [Expanded(child: ...), ...]));
   ```
2. ```
   Use a ShrinkWrappingViewport or set the ListView's shrinkWrap: true and neverScrollableScrollPhysics: true to allow the Column to calculate its own height.
   ```
3. ```
   Replace the scrollable parent with a NonScrollableColumn or use a CustomScrollView with slivers that provide bounded constraints.
   ```

## 无效尝试

- **Wrap the Column in a SizedBox with a fixed height** — A fixed height may not adapt to different screen sizes and can cause overflow on smaller devices. (50% 失败率)
- **Replace Expanded with Flexible without flex value** — Flexible still requires a bounded constraint; the error persists if the parent is unbounded. (70% 失败率)
