Flutter 如何使用Extended with InkWell来解决由像素溢出的Renderflex
当我单击一个项目时,项目在“child:Column”行崩溃Flutter 如何使用Extended with InkWell来解决由像素溢出的Renderflex,flutter,dart,flutter-widget,Flutter,Dart,Flutter Widget,当我单击一个项目时,项目在“child:Column”行崩溃 Widget renderEditableParamItem(EditableStructParam data) { return InkWell( onTap: () => _bloc.onEditableItemSelected(data), child: Container( margin: EdgeInsets.only(left: 15, right: 15)
Widget renderEditableParamItem(EditableStructParam data) {
return InkWell(
onTap: () => _bloc.onEditableItemSelected(data),
child: Container(
margin: EdgeInsets.only(left: 15, right: 15),
padding: EdgeInsets.all(10),
child: Column(
children: <Widget>[
Text(
data.title,
style: TextStyle(
color: Colors.white,
fontSize: 16,
),
),
],
),
));
}
你知道这里怎么用吗
作为一个孩子,我尝试返回使用InkWell扩展的,但它仍然崩溃。扩展应该在孩子大小没有限制的情况下使用。在您的情况下,文本小部件使用更大的字符串增加其大小。因此,您应该使用扩展的文本小部件包装文本小部件。欲了解更多信息,请浏览
小部件RenderiTableParamItem(EditableStructParam数据){
回墨槽(
onTap:()=>_bloc.onEditableItemSelected(数据),
子:容器(
边距:仅限边集(左:15,右:15),
填充:边缘设置。全部(10),
子:列(
儿童:[
扩大(
子:文本(
data.title,
样式:TextStyle(
颜色:颜色,白色,
尺寸:16,
),
),
)
],
),
));
}
我不太清楚为什么文本在列中。如果你能提供更多的上下文,帮助会更容易。你能添加一个截图吗?
The overflowing RenderFlex has an orientation of Axis.vertical.
I/flutter (23777): The edge of the RenderFlex that is overflowing has been marked in the rendering with a yellow and
I/flutter (23777): black striped pattern. This is usually caused by the contents being too big for the RenderFlex.
I/flutter (23777): Consider applying a flex factor (e.g. using an Expanded widget) to force the children of the
I/flutter (23777): RenderFlex to fit within the available space instead of being sized to their natural size.
I/flutter (23777): This is considered an error condition because it indicates that there is content that cannot be
I/flutter (23777): seen. If the content is legitimately bigger than the available space, consider clipping it with a
I/flutter (23777): ClipRect widget before putting it in the flex, or using a scrollable container rather than a Flex,
I/flutter (23777): like a ListView.
Widget renderEditableParamItem(EditableStructParam data) {
return InkWell(
onTap: () => _bloc.onEditableItemSelected(data),
child: Container(
margin: EdgeInsets.only(left: 15, right: 15),
padding: EdgeInsets.all(10),
child: Column(
children: <Widget>[
Expanded(
child: Text(
data.title,
style: TextStyle(
color: Colors.white,
fontSize: 16,
),
),
)
],
),
));
}