简体   繁体   English

使 Column force Container 与其他小部件 Flutter 的大小相同

[英]Make a Column force Container to be same size as other widgets Flutter

A DartPad example is here: https://dartpad.dev/cf6ab1d34f5b1022aa48ea8ced193de5 . DartPad 示例如下: https ://dartpad.dev/cf6ab1d34f5b1022aa48ea8ced193de5。

I am trying to make a fraction display, but I cannot get the container that is the fraction bar to not expand to the entire screen.我正在尝试进行分数显示,但我无法让作为分数栏的容器不扩展到整个屏幕。 This is the code I have right now:这是我现在拥有的代码:

Center(
   child: Column(
       children: <Widget>[
          Text("100"),
          Container(
              height: 2,
              color: Colors.black,
          ),
          Text("300"),
       ],
    ),
 )

Use IntrinsicWidth :使用IntrinsicWidth

IntrinsicWidth(
  child: Column(
    children: [
      Text("100"),
      Container(
        height: 2,
        color: Colors.black,
      ),
      Text("300"),
    ],
  ),
)

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

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