【发布时间】:2019-10-08 04:27:37
【问题描述】:
我在 Flutter 中开发了一个应用程序,其中包含很多不同的动画。我想通过分离视图、逻辑(模型 BLoC)和动画来构造我的代码。对于这个问题,我尝试为我的 StatefulWidget 的不同类中的按钮声明多次相同的动画。
但是,我被卡住了,因为我必须将 TickerProvider 传递给我的动画类,而且我的做法不正确。
构造函数动画类
AppBloc(TickerProvider tickerProvider) {
banimationController = AnimationController(
vsync: tickerProvider,
duration: Duration(milliseconds: 100),
lowerBound: 0,
upperBound: 0.05,
);
}
声明
AppBloc(this);
我知道这可能不是正确的方法,我写了这段代码来说明我的问题。
我只想将我的动画声明分隔到另一个文件中。
【问题讨论】: