Flare Flutter动画

时间:2019-08-30 11:57:41

标签: flutter flutter-layout flutter-animation flare flare3d

我正在尝试调用动画(我得到了),但是我希望在完成后将其转到另一个页面。如何设置路由系统或如何使动画完成并调用另一个屏幕?

    return Scaffold(

      body: Stack(

        children: <Widget>[

          Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Container(
                    width: 400,
                    height: 400,
                    alignment: Alignment.center,
                    child: FlareActor(
                      "assets/animations/LoadingM.flr",
                      alignment: Alignment.center,
                      fit: BoxFit.contain,
                      color: Colors.blue,
                      animation: _animationL,
                    ),
                  ),
                ],
              )
            ],
          )
        ],
      ),
    );
  }
}

1 个答案:

答案 0 :(得分:0)

这真的很简单,您只需将回调属性添加到FlareActor中即可。

return Scaffold(

      body: Stack(

        children: <Widget>[

          Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Container(
                    width: 400,
                    height: 400,
                    alignment: Alignment.center,
                    child: FlareActor(
                      "assets/animations/LoadingM.flr",
                      alignment: Alignment.center,
                      fit: BoxFit.contain,
                      color: Colors.blue,
                      animation: _animationL,
                      callback: (String animationName) {
                        //Navigate to new page here
                        //hint: the animationName parameter tells you the name
                        //      of the animation that finished playing
                      },
                    ),
                  ),
                ],
              )
            ],
          )
        ],
      ),
    );