Search code examples
flutterflutter-layout

Flutter Animation Controller The argument type 'ExampleWidget' or 'this' can't be assigned to the parameter type 'TickerProvider'


I'm following this guide for an animation: https://mightytechno.com/flutter-glow-pulse-animation/

When I go to use this it won't let me pass it. I can't compile and flutter clean does nothing. What object can I pass to get rid of this error?

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

      });
    });

Solution

  • Extending SingleTickerProviderStateMixin fixed the issue:

    class Social4state extends State<UserProfilePage> with SingleTickerProviderStateMixin{