【发布时间】:2021-01-14 07:22:35
【问题描述】:
我尝试为小部件切换位置制作动画。下图显示了 A 和 B 小部件,我想在单击按钮时在 A 到 B / B 到 A 之间切换。但是一开始我不知道从哪里开始,不知道有没有什么插件可以实现,任何建议都可以帮助我,只是和一些技巧,我愿意研究建议插件。
我尝试使用 AnimatedAlign
Container(
height: 120.0,
color: Colors.black,
child: Column(
children: [
AnimatedAlign(
alignment: _alignment.value = _alignment.value == Alignment.topCenter ? Alignment.bottomCenter : _alignment.value,
curve: Curves.ease,
duration: Duration(milliseconds: 500),
child: Padding(
padding: EdgeInsets.all(2.5),
child: Container(
height: 55,
color: Colors.red,
),
)
),
AnimatedAlign(
alignment: _alignment.value = _alignment.value == Alignment.bottomCenter ? Alignment.topCenter : _alignment.value,
curve: Curves.ease,
duration: Duration(milliseconds: 500),
child: Padding(
padding: EdgeInsets.all(2.5),
child: Container(
height: 55,
color: Colors.blue,
),
),
)
],
),
),
RaisedButton(
onPressed: () {
_alignment.value = Alignment.bottomCenter;
},
child: Text("Switch Position"),
)
【问题讨论】:
-
你看到这个小部件了吗? youtube.com/watch?v=2W7POjFb88g
-
@mohandesR 不,但是我看了之后,这不是那个,因为我需要的是 A 和 B 仍然存在,只是交换它们的位置