【发布时间】:2021-02-03 19:06:58
【问题描述】:
我目前在 AnimatedContainer 中使用 AnimatedContainer 和 LinearProgressIndicator。这是我当前的代码:
LayoutBuilder(
builder: (context, constraints) => AnimatedContainer(
width: expanded ? constraints.maxWidth : 0,
duration: Duration(milliseconds: 250),
child: Container(
color: Colors.red,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(trackName, maxLines: 1, overflow: TextOverflow.ellipsis),
Text(artists.join(", "), maxLines: 1, overflow: TextOverflow.ellipsis),
if (currentProgressValue != null)
Row(
children: [
Text(currentProgress.minutes.toString() + ":" + currentProgress.seconds.toString(),
maxLines: 1, overflow: TextOverflow.ellipsis),
Expanded(
child: LinearProgressIndicator(
valueColor: new AlwaysStoppedAnimation<Color>(MyTheme.primaryColor),
value: currentProgressValue / songDuration,
),
),
],
),
],
),
),
),
),
问题是在“if (currentProgressValue != null)”之后的第一个文本在 AnimatedContainer 压缩时溢出。有效的解决方案是将 Text 和 LinearProgressIndicator 都放在 Expanded 内,但这样做会将空间分成两半,这不是我想要的。我不会使用 LinearProgressIndicator 来填充文本的剩余空间。你知道如何解决这个问题吗?
【问题讨论】: