gpt4 book ai didi

Flutter Animation Controller 参数类型 'ExampleWidget'或 'this'不能赋值给参数类型 'TickerProvider'

转载 作者:行者123 更新时间:2023-12-02 16:04:14 25 4
gpt4 key购买 nike

我正在按照本指南制作动画:https://mightytechno.com/flutter-glow-pulse-animation/

当我去使用this时,它不会让我通过它。我无法编译并且 flutter clean 什么都不做。我可以传递什么对象来消除此错误?

enter image description here

void initState() {    
getSharedPrefs();
_animationController = AnimationController(vsync: this, duration: Duration(seconds: 2));
_animationController.repeat(reverse: true);
_animation = Tween(begin: 2.0,end: 15.0).animate(_animationController)..addListener((){
setState(() {

});
});

最佳答案

扩展SingleTickerProviderStateMixin修复了问题:

class Social4state extends State<UserProfilePage> with SingleTickerProviderStateMixin{

关于Flutter Animation Controller 参数类型 'ExampleWidget'或 'this'不能赋值给参数类型 'TickerProvider',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69878272/

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