Flutter,第二个动画控制器没有动画,为什么?
Flutter, the second animation controller is not animating, why?
我有两个使用 TickerProviderStateMixin 的动画控制器,第一个动画运行顺利,而第二个在我触发它时没有动画 forward 方法: 这是他们的声明 :
class HomeAnimator extends StatefulWidget {
@override
_HomeAnimatorState createState() => _HomeAnimatorState();
}
class _HomeAnimatorState extends State<HomeAnimator>
with TickerProviderStateMixin {
AnimationController _controller;
AnimationController _signupctrl;
@override
void initState() {
super.initState();
_controller =
AnimationController(duration: Duration(milliseconds: 900), vsync: this);
_signupctrl =
AnimationController(duration: Duration(milliseconds: 900), vsync: this);
// _controller.forward();
}
@override
void dispose() {
super.dispose();
_controller.dispose();
_signupctrl.dispose();
}
@override
Widget build(BuildContext context) {
return Dahome(controllers: [_controller,_signupctrl]);
}
}
我有两个文件用于不同的动画集:
-- Mahome_EnterAnimation: 当点击登录按钮时
这是一篇相关文章:
class EntAnime {
EntAnime(this.controller)
: opanime = Tween<double>(begin: 1, end: 0).animate(CurvedAnimation(
parent: controller,
curve: Interval(0, 0.5, curve: Curves.fastOutSlowIn),
)),
r_opanime = Tween<double>(begin: 0, end: 1).animate(CurvedAnimation(
parent: controller,
curve: Interval(0, 0.5, curve: Curves.fastOutSlowIn),
)),
hfact = Tween<double>(begin: 0, end: 1).animate(CurvedAnimation(
parent: controller,
curve: Interval(0, 0.5, curve: Curves.fastOutSlowIn),
)),
-- Mahome_SignupAnime: 当我按下注册按钮时
class SignupAnime {
SignupAnime(this.controller):
qopanime = Tween<double>(begin: 0, end: 1).animate(CurvedAnimation(
parent: controller,
curve: Interval(0.0, 0.5, curve: Curves.fastOutSlowIn),
)),
qhfact = Tween<double>(begin: 0, end: 1).animate(CurvedAnimation(
parent: controller,
curve: Interval(0.5, 0.9, curve: Curves.fastOutSlowIn),
));
final AnimationController controller;
final Animation<double> qopanime;
final Animation<double> qhfact;
}
我是这样声明的:
class Dahome extends StatefulWidget {
Dahome({Key key, this.title, @required List<AnimationController> controllers})
: daanime = EntAnime(controllers[0]),
signanime = SignupAnime(controllers[1]),
super(key: key);
final EntAnime daanime;
final SignupAnime signanime;
final String title;
Dastate createState() => Dastate(daanime, signanime);
// @override
}
class Dastate extends State<Dahome> {
Dastate(this.maanime, this.loganime);
final EntAnime maanime;
final SignupAnime loganime;
...
我在两个不同的按钮中调用了转发方法:
第一个在这里,第二个也是这样:
RaisedButton(
onPressed: () => {
maanime.controller.forward()
},
愚蠢的我,问题是 animatedbuilder
小部件我不得不用第二个控制器
更改 animation
参数
我有两个使用 TickerProviderStateMixin 的动画控制器,第一个动画运行顺利,而第二个在我触发它时没有动画 forward 方法: 这是他们的声明 :
class HomeAnimator extends StatefulWidget {
@override
_HomeAnimatorState createState() => _HomeAnimatorState();
}
class _HomeAnimatorState extends State<HomeAnimator>
with TickerProviderStateMixin {
AnimationController _controller;
AnimationController _signupctrl;
@override
void initState() {
super.initState();
_controller =
AnimationController(duration: Duration(milliseconds: 900), vsync: this);
_signupctrl =
AnimationController(duration: Duration(milliseconds: 900), vsync: this);
// _controller.forward();
}
@override
void dispose() {
super.dispose();
_controller.dispose();
_signupctrl.dispose();
}
@override
Widget build(BuildContext context) {
return Dahome(controllers: [_controller,_signupctrl]);
}
}
我有两个文件用于不同的动画集:
-- Mahome_EnterAnimation: 当点击登录按钮时 这是一篇相关文章:
class EntAnime {
EntAnime(this.controller)
: opanime = Tween<double>(begin: 1, end: 0).animate(CurvedAnimation(
parent: controller,
curve: Interval(0, 0.5, curve: Curves.fastOutSlowIn),
)),
r_opanime = Tween<double>(begin: 0, end: 1).animate(CurvedAnimation(
parent: controller,
curve: Interval(0, 0.5, curve: Curves.fastOutSlowIn),
)),
hfact = Tween<double>(begin: 0, end: 1).animate(CurvedAnimation(
parent: controller,
curve: Interval(0, 0.5, curve: Curves.fastOutSlowIn),
)),
-- Mahome_SignupAnime: 当我按下注册按钮时
class SignupAnime {
SignupAnime(this.controller):
qopanime = Tween<double>(begin: 0, end: 1).animate(CurvedAnimation(
parent: controller,
curve: Interval(0.0, 0.5, curve: Curves.fastOutSlowIn),
)),
qhfact = Tween<double>(begin: 0, end: 1).animate(CurvedAnimation(
parent: controller,
curve: Interval(0.5, 0.9, curve: Curves.fastOutSlowIn),
));
final AnimationController controller;
final Animation<double> qopanime;
final Animation<double> qhfact;
}
我是这样声明的:
class Dahome extends StatefulWidget {
Dahome({Key key, this.title, @required List<AnimationController> controllers})
: daanime = EntAnime(controllers[0]),
signanime = SignupAnime(controllers[1]),
super(key: key);
final EntAnime daanime;
final SignupAnime signanime;
final String title;
Dastate createState() => Dastate(daanime, signanime);
// @override
}
class Dastate extends State<Dahome> {
Dastate(this.maanime, this.loganime);
final EntAnime maanime;
final SignupAnime loganime;
...
我在两个不同的按钮中调用了转发方法:
第一个在这里,第二个也是这样:
RaisedButton(
onPressed: () => {
maanime.controller.forward()
},
愚蠢的我,问题是 animatedbuilder
小部件我不得不用第二个控制器
animation
参数