본문 바로가기
프로그래밍/Flutter <Dart>

[Flutter] Incorrect use of ParentDataWidget 에러 해결

by TaeGyeong Lee 2024. 9. 18.

개요 

======== Exception caught by widgets library =======================================================
The following assertion was thrown while applying parent data.:
Incorrect use of ParentDataWidget.

The ParentDataWidget Expanded(flex: 1) wants to apply ParentData of type FlexParentData to a RenderObject, which has been set up to accept ParentData of incompatible type ParentData.

Usually, this means that the Expanded widget has the wrong ancestor RenderObjectWidget. Typically, Expanded widgets are placed directly inside Flex widgets.
The offending Expanded is currently placed inside a ConstrainedBox widget.

 

해결 

Expanded 의 부모 위젯을 Colunm Row Flex가 아닌 이외의 위젯, 예를 들어 ConstraintBox 위젯으로 설정했을 경우 발생합니다. 

 

참고 자료 

 

Incorrect use of parent data widget. expanded widgets must be placed inside flex widgets

I am getting the following error: i.e.., Another exception was thrown: Incorrect use of ParentDataWidget. showing error on the mobile screen. @override Widget build(BuildContext context) {

stackoverflow.com

 

[Flutter] Incorrect use of ParentDataWidget.

상황 Expanded를 위젯들에 감싸면서 레이아웃을 잡던 중 에러가 발생했습니다. 문제 파악 Expanded로는 간격을 줄 수 있는 위젯이 정해져있었습니다. 해결 방법 https://stackoverflow.com/questions/54905388/incor

otrodevym.tistory.com