flutter - 使“列强制容器”与其他小部件的大小相同

标签 flutter dart

DartPad示例在这里:https://dartpad.dev/cf6ab1d34f5b1022aa48ea8ced193de5

我正在尝试显示分数,但无法获得作为分数栏的容器,因此无法展开到整个屏幕。这是我现在拥有的代码:

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

最佳答案

使用IntrinsicWidth:

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

关于flutter - 使“列强制容器”与其他小部件的大小相同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59364779/

相关文章:

flutter - 仅基于Type实例在Dart中进行类型继承检查

typescript - Dart 中的 Crypto.subtle?

node.js - 在Flutter App中检查Firebase Auth中是否已存在电子邮件

dart - Dart 中的 curl 功能

firebase - 如何使用flutter中的Map在Firestore中动态添加特定集合的文档的字段?

android - 为什么在 flutter 中的 build 者在这里破裂

flutter - children 有非零弹性,但传入的高度限制是无限的

ios - 在 iOS 模拟器上以 Release模式 Flutter 启动应用程序时出现问题

dart - 使用Flutter导航和路线时如何保持BottomNavigationBar

stream - Dart中是否有 “observable”集或列表?