我在Table
中有以下Card
。由于添加了padding小部件,因此出现以下错误:
I/flutter (19671): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (19671): The following assertion was thrown during performLayout():
I/flutter (19671): 'package:flutter/src/rendering/table.dart': Failed assertion: line 882 pos 16: 'tableWidth >=
I/flutter (19671): targetWidth': is not true.
I/flutter (19671):
I/flutter (19671): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter (19671): more information in this error message to help you determine and fix the underlying cause.
I/flutter (19671): In either case, please report this assertion by filing a bug on GitHub:
I/flutter (19671): https://github.com/flutter/flutter/issues/new?template=BUG.md
I/flutter (19671):
I/flutter (19671): When the exception was thrown, this was the stack:
I/flutter (19671): #2 RenderTable._computeColumnWidths (package:flutter/src/rendering/table.dart:882:16)
I/flutter (19671): #3 RenderTable.performLayout (package:flutter/src/rendering/table.dart:1000:33)
代码:
body: Container(
padding: EdgeInsets.all(5.0), margin: EdgeInsets.all(10.0),
child: Card(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Table(
children: list)
])
)
)
答案 0 :(得分:0)
由于值为2,因此不会根据填充物说明容器的增长,它将向内填充,导致内部溢出。只需使用Container中提供的属性即可。
容器具有可以应用的padding和margin属性。您不必用填充物包裹您的Containers子项。
容器( 子级:Text(), 填充:EdgeInsets.all(5.0), 边距:EdgeInsets.all(10.0) )
有关可用的更多属性,请参见Container-class