# FlutterError：RenderBox 未布局：RenderRepaintBoundary#12345 relayoutBoundary=up1 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE

- **ID:** `flutter/render-box-intersect-error`
- **领域:** flutter
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

在 RenderBox 布局完成前访问其几何属性，通常是因为在 initState 或第一帧之前调用了 RenderBox.size。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Flutter 3.7 | active | — | — |
| Flutter 3.10 | active | — | — |
| Dart 3.0 | active | — | — |

## 解决方案

1. ```
   Delay RenderBox access until after the first frame using WidgetsBinding.instance.addPostFrameCallback and then access the GlobalKey's currentContext.size.
   ```
2. ```
   Use a LayoutBuilder to get constraints and size without directly accessing RenderBox.
   ```

## 无效尝试

- **** — SizedBox forces a size but does not ensure layout is complete before accessing RenderBox; the underlying widget may still not be laid out. (70% 失败率)
- **** — addPostFrameCallback runs after the first frame, but if accessed before the callback fires, the error persists. (50% 失败率)
- **** — The context may exist but the RenderBox may not be laid out yet; size is null until layout completes. (60% 失败率)
