【问题标题】:How to add reveal in animation at the start of a screen in flutter如何在颤动的屏幕开始处添加动画显示
【发布时间】:2021-03-13 13:01:53
【问题描述】:

我有一个应用程序,我想要一个“显示动画”,当屏幕初始化时,我想要的元素看起来像是在屏幕内“移动”。我认为使用AnimatedPositioned 将是正确的选择,但我无法使用我现在拥有的代码。我的元素位于以下小部件层次结构中,因此请相应回答。

Scaffold
 - Row 
  - Padding
   - Column
    - Container (widget I want to reveal in)
    - Container (widget I want to reveal in)
  - Padding
   - Column
    - Container (widget I want to reveal in)
    - Container (widget I want to reveal in)

【问题讨论】:

    标签: flutter animation widget


    【解决方案1】:

    我建议使用 PositionedTransition,您可以在其中设置开始和结束。你可以试试follow this article。我是这样工作的:

    PositionedTransition(
                  rect: RelativeRectTween(
                    begin: RelativeRect.fromLTRB(0.0, 0.0, 0.0, 0.0),
                    end: RelativeRect.fromLTRB(100.0, 100.0, 0.0, 0.0),
                  ).animate(_animationController),
                  child: Container(width: 100, height: 100, color: Colors.red,),
                ),
    

    如果有帮助,请告诉我。干杯

    【讨论】:

    • smallLogo 和 bigLogo 是什么意思?
    • 这是示例中的代码。我用更简单的方法编辑了答案。您将不得不调整 RelativeRectTween 和动画以实现您想要的动画
    猜你喜欢
    • 2020-06-01
    • 1970-01-01
    • 2019-08-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多