刚才运行项目碰到一个错,错误本身比较简单,记在这主要给自己一个提醒,多看报错信息,别直接马上复制错误信息 Google Incorrect use of parent data widget. expanded widgets must be placed inside flex widgets。。。
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.
报错提供的信息很全也很明显,Expanded
的父控件必须是 Flex
。当然,因为Row
和Column
都继承Flex
,所以也支持。简单来说,Expanded
只能放到 Column
, Row
和 Flex
中使用。
本文由老郭种树原创,转载请注明:https://guozh.net/the-parentdatawidget-expanded-is-incorrect/