Flutter动画控制器参数类型“ExampleWidget”或“this”无法分配给参数类型“TickerProvider”

Pet*_*tro 2 flutter flutter-layout

我正在遵循本动画指南:https ://mightytechno.com/flutter-glow-pulse-animation/

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

在此输入图像描述

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(() {

      });
    });
Run Code Online (Sandbox Code Playgroud)

Pet*_*tro 6

扩展SingleTickerProviderStateMixin解决了这个问题:

class Social4state extends State<UserProfilePage> with SingleTickerProviderStateMixin{