Just learning flutter Animation. using with SingleTickerProviderStateMixin IDE giving me this error : 
The class 'SingleTickerProviderStateMixin' can't be used as a mixin because it extends a class other than Object
My code:
  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();
    }
  }
What's my problem in code?
SingleTickerProviderStateMixin is a mixin we can add to our StatelessWidget which will give us access to a Ticker . Ticker is a class that fires a callback once per animation frame. AnimationController is a class that allows us to control animations via methods like forward() , reverse() , and isAnimating .
A mixin is a class with methods and properties utilized by other classes in Dart. It is a way to reuse code and write code clean. To declare a mixin, we use the mixin keyword: mixin Mixin_name{ } Mixins, in other words, are regular classes from which we can grab methods (or variables) without having to extend them.
Add to analysis_options.yaml
analyzer:
  language:
    enableSuperMixins: true
See also https://github.com/flutter/flutter/blob/master/analysis_options.yaml#L24
I my case I used SingleTickerProviderStateMixin, Please just use  TickerProviderStateMixin instead of SingleTickerProviderStateMixin
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With