[Flutter] RenderBox was not laid out

gozero·2021년 7월 5일
0

에러 코드

RenderBox was not laid out: RenderViewport#925a8 NEEDS-LAYOUT NEEDS-PAINT
Another exception was thrown: RenderBox was not laid out: RenderViewport#925a8 NEEDS-PAINT
Another exception was thrown: RenderBox was not laid out: RenderIgnorePointer#8bbda relayoutBoundary=up11 NEEDS-PAINT
Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#209b4 relayoutBoundary=up10 NEEDS-PAINT
Another exception was thrown: RenderBox was not laid out: RenderPointerListener#a9641 relayoutBoundary=up9 NEEDS-PAINT
Another exception was thrown: RenderBox was not laid out: RenderSemanticsGestureHandler#9f5b4 relayoutBoundary=up8 NEEDS-PAINT
Another exception was thrown: RenderBox was not laid out: _RenderScrollSemantics#47944 relayoutBoundary=up7 NEEDS-PAINT
Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#e17a8 relayoutBoundary=up6 NEEDS-PAINT
Another exception was thrown: RenderBox was not laid out: RenderCustomPaint#a2328 relayoutBoundary=up5 NEEDS-PAINT
Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#02607 relayoutBoundary=up4 NEEDS-PAINT
Another exception was thrown: RenderBox was not laid out: RenderFlex#79164 relayoutBoundary=up3 NEEDS-PAINT
Another exception was thrown: 'package:flutter/src/rendering/shifted_box.dart': Failed assertion: line 310 pos 12: 'child.hasSize': is not true.
Another exception was thrown: NoSuchMethodError: The method '<=' was called on null.

해결 방법

1. Expanded Widget 사용

Column(
  children: <Widget>[
    Expanded(
      child: ListView(...),
    )
  ],
)

2. Flexible Widget 사용

Column(
  children: <Widget>[
    Flexible(
      child: ListView(...),
    )
  ],
)

3. SizedBox Widget 사용

Column(
  children: <Widget>[
    SizedBox(
      height: 200,
      child: ListView(),
    )
  ],
)

4. ListView의 shrinkWrap 사용

Column(
  children: <Widget>[
    ListView(
      shrinkWrap: true,
    )
  ],
)
profile
Flutter를 제일 좋아하는 앱 프론트엔드 개발자입니다!

0개의 댓글