简体   繁体   English

在 flutter 中使用 Future.delayed 重置 animation 是一种好的做法吗?

[英]Is it good practice in flutter to reset an animation with a Future.delayed?

I have an AnimatedCrossfade in a StatefulWidget.我在 StatefulWidget 中有一个 AnimatedCrossfade。 The crossFadeState is depending on a variable which comes as a return value from another page. crossFadeState 取决于一个变量,该变量作为另一个页面的返回值。

When the variable has a certain value, the firstChild is shown, otherwise the secondChild, - nothing special so far..当变量具有特定值时,显示第一个孩子,否则显示第二个孩子, - 到目前为止没有什么特别的......

After a Future.delayed I reset this variable and the firstChild is shown again via setState.在 Future.delayed 之后,我重置了这个变量,并且通过 setState 再次显示了 firstChild。

Is this a good flutter practice?这是一个很好的 flutter 做法吗?

Try reading "Tween animation" I guess that will answer your question because in every moving animation, you want to reset it so that the starting value of the animation begin at 0 again until it reach the end value.尝试阅读“补间动画”,我想这将回答您的问题,因为在每个移动的 animation 中,您都希望将其重置,以便 animation 的起始值再次从 0 开始,直到达到结束值。 And it will repeat the process over and over again它会一遍又一遍地重复这个过程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM