小于Flutter中列的子元素之间的空间小于MainAxisSize.min

问题描述 投票:0回答:1

我已经阅读了有关在Column中的子级之间增加间距的一些讨论,但是我想使它们彼此更靠近。我想要这样的2个文本:

enter image description here

我现在的代码,这使'Days'文本与数字相距太远:

Widget numberOfDays = Container(
  child: Column(
    mainAxisSize: MainAxisSize.min,
    children: <Widget>[
     Text(
        '$_counter', // 25
        style: Theme.of(context).textTheme.display4,
      ),
     Text(
        'Days',
        style: Theme.of(context).textTheme.caption,
      ),
    ],
  ),
);

也许无法使用专栏吗?我是否应该使用堆栈并相应地放置它们?谢谢。

flutter flutter-layout
1个回答
1
投票

您是否正在寻找类似的东西?

Stack(
  children: <Widget>[
    Text(
      '25', // 25
      style: Theme.of(context).textTheme.display4,
    ),
    Positioned(
      right: 0,
      bottom: 10,
      child: Text(
        'Days',
        style: Theme.of(context).textTheme.caption,
      ),
    )
  ],
)

输出:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.