gpt4 book ai didi

android - 错误 : The class 'SingleTickerProviderStateMixin' can't be used as a mixin because it extends a class other than Object

转载 作者:IT老高 更新时间:2023-10-28 12:40:01 28 4
gpt4 key购买 nike

刚学flutter动画。使用 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

关于android - 错误 : The class 'SingleTickerProviderStateMixin' can't be used as a mixin because it extends a class other than Object,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51346911/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com