只是学习扑动动画.使用SingleTickerProviderStateMixin IDE给我这个错误:
The class ‘SingleTickerProviderStateMixin’ can’t be used as a mixin because
it extends a class other than Object
我的代码:
import 'package:flutter/material.dart';
class AnimationControllerOutputBody extends StatefulWidget with {
@override
_AnimationControllerOutputBodyState createState() =>
new _AnimationControllerOutputBodyState();
}
class _AnimationControllerOutputBodyState extends State<AnimationControllerOutputBody> with SingleTickerProviderStateMixin {
AnimationController animation;
@override
void initState() {
super.initState();
animation = new AnimationController(
vsync: this,
duration: new Duration(seconds: 3),
);
animation.addListener(() {
this.setState(() {});
});
}
@override
Widget build(BuildContext context) {
return new GestureDetector(
child: new Center(
child: new Text(
animation.isAnimating
? animation.value.toStringAsFixed(3)
: "Tap me!",
style: new TextStyle(
fontSize: 50.0,
),
),
),
onTap: () {
animation.forward(from: 0.0);
},
);
}
@override
void dispose() {
animation.dispose();
super.dispose();
}
}
我的代码有什么问题?
解决方法:
添加到analysis_options.yaml
analyzer:
language:
enableSuperMixins: true
另见https://github.com/flutter/flutter/blob/master/analysis_options.yaml#L24
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。