The ParentDataWidget Expanded Is Incorrect

刚才运行项目碰到一个错,错误本身比较简单,记在这主要给自己一个提醒,多看报错信息,别直接马上复制错误信息 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。当然,因为RowColumn都继承Flex,所以也支持。简单来说,Expanded 只能放到 ColumnRowFlex中使用。

本文由老郭种树原创,转载请注明:https://guozh.net/the-parentdatawidget-expanded-is-incorrect/

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注