【发布时间】:2020-06-20 14:46:09
【问题描述】:
我试图在我的 Expanded 小部件中放置一个 AnimatedContainer(因为将 AnimatedContainer 作为父级会引发 Flex 错误),因为我正在使用一个事件在三个可能的条件下调整两个 Expanded 容器的大小。两者都以 50/50 的弹性尺寸开始,然后在第二个条件下变为 25/75,最后一个条件为 75/25。它在没有 Animated 容器的情况下运行良好,但大小转换是即时的,我希望它具有动画效果。
这基本上是目前的设置方式:
Flex(
direction: Axis.horizontal,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Expanded( // <--- I would like to get the current width of this
flex: (target[expController.target]["newsWidth"]),
child: AnimatedContainer(
width: ?, // <-- and use it here
duration: Duration(milliseconds: 500),
curve: Curves.fastOutSlowIn,
child: NewsMainHome(),
),
),
Spacer(flex: target[expController.target]["spacer"]),
Expanded(
flex: (target[expController.target]["changeLogWidth"]),
child: AnimatedContainer(
width: ?, // Set to parent size
duration: Duration(milliseconds: 500),
curve: Curves.fastOutSlowIn,
child: ChangeLogList(),
),
),
],
),
如果能够将 AnimatedContainer 宽度设置为父级 Expanded 宽度的大小,那么当 Expanded flex 值从事件发生变化时,它会为大小转换设置动画,但我还没有找到合适的方法去做吧。有什么想法/建议吗?
谢谢,
-MH
【问题讨论】:
标签: flutter