在进行 Flutter UI 开发的时候,控制台报出了下面错误:
The following assertion was thrown during layout:
A RenderFlex overflowed by 1.4 pixels on the bottom.
The relevant error-causing widget was:
下面会有会有黄黑相间的斜线,页面展示的:
这是我自己的代码块:
child: Column(
children: <Widget>[
ExtendedImage.network(
subcategory.image,
width: ScreenUtil().setWidth(200),
fit: BoxFit.cover,
cache: true,
borderRadius: BorderRadius.all(Radius.circular(30.0)),
),
Text(
subcategory.categoryName,
style: TextStyle(
color: currentSubCategory == subcategory.categoryId.toString() ? Colors.pinkAccent : Colors.black),
)
],
)
根据网上找的资料来看,这个问题的原因是,在高度不确定的组件中使用了高度不确定的组件,很多情况下,都是可以用expanded来解决。
官网有如下解释:
A widget that expands a child of a Row, Column, or Flex.
所以这里我修改:
child: Column(
children: <Widget>[
Expanded(
child: ExtendedImage.network(
subcategory.image,
width: ScreenUtil().setWidth(200),
fit: BoxFit.cover,
cache: true,
borderRadius: BorderRadius.all(Radius.circular(30.0)),
)),
Text(
subcategory.categoryName,
style: TextStyle(
color: currentSubCategory == subcategory.categoryId.toString() ? Colors.pinkAccent : Colors.black),
)
],
)
效果如下: