Incorrect use of ParentDataWidget "Not similar to others"


I am getting this error while debugging although it is not creating any issue. Still can someone tell problems created by this warning. My code file is very big I can’t share it but it is giving map of my widget tree. Can someone please tell me where the error is lying

Row ← Expanded ← Padding ← DecoratedBox ← Padding ← Container ← Expanded ← Column ← Padding ← Padding ←

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 BoxParentData. 
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 Padding widget.

The ownership chain for the RenderObject that received the incompatible parent data was:
  Row ← Expanded ← Padding ← DecoratedBox ← Padding ← Container ← Expanded ← Column ← Padding ← Padding ← ⋯
When the exception was thrown, this was the stack
#0      RenderObjectElement._updateParentData.<anonymous closure>
#1      RenderObjectElement._updateParentData
#2      RenderObjectElement.attachRenderObject
#3      RenderObjectElement.mount
#4      MultiChildRenderObjectElement.mount


You have an expanded widget as the child of a container widget and that is not permitted in Flutter.

An expanded widget should only be direct child of widgets such as Column, Row, …

Answered By – Gaspard Merten

Answer Checked By – Cary Denson (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *