简体   繁体   English

添加Padding小部件后出现Flutter异常

[英]Flutter exception after adding the Padding widget

I have the following Table inside Card . 我在Card有以下Table Since I added the padding widget, I get the following error: 由于添加了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)

code: 码:

body: Container(
          padding: EdgeInsets.all(5.0), margin: EdgeInsets.all(10.0),
            child: Card(
                child: Column(
                    mainAxisSize: MainAxisSize.min,
                    children: <Widget>[
                      Table(
                          children: list)
                    ])
            )
      )
  1. Why adding the padding widget throws this error? 为什么添加padding小部件会引发此错误?
  2. How I can add padding and margin for my Card? 如何为卡添加填充和边距?
  1. Because of 2 it won't account for growth in the container based on the padding, it will pad inward causing the inners to overflow. 由于2的关系,它不会根据填充物说明容器的增长,它将向内填充,从而导致内部溢出。 Just use the provided properties from Container. 只需使用Container提供的属性即可。

  2. Container has a padding and margin property which can be applied. 容器具有可以应用的padding和margin属性。 You don't nee to wrap your Containers child with padding. 您不必用填充物包裹您的“容器”子级。

    Container( child: Text(), padding: EdgeInsets.all(5.0), margin: EdgeInsets.all(10.0) ) Container(子代:Text(),填充:EdgeInsets.all(5.0),边距:EdgeInsets.all(10.0))

See Container-class for more properties that can be used 请参阅容器类以获取更多可以使用的属性

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM