Flutter   发布时间:2022-05-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – 错误:类’SingleTickerProviderStateMixin’不能用作mixin,因为它扩展了Object以外的类大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
只是学习扑动动画.使用SingleTickerProviderStatemixin IDE给我这个错误

我的代码

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 – 错误:类’SingleTickerProviderStateMixin’不能用作mixin,因为它扩展了Object以外的类全部内容,希望文章能够帮你解决android – 错误:类’SingleTickerProviderStateMixin’不能用作mixin,因为它扩展了Object以外的类所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。