android - 错误 : The class 'SingleTickerProviderStat

刚学flutter动画。使用 SingleTickerProviderStateMixin IDE 给我这个错误:

The class 'SingleTickerProviderStateMixin' can't be used as a mixin because it extends a class other than Object

我的代码:

  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 - 错误 : The class 'SingleTickerProviderStateMixin' can't be used as a mixin because it extends a class other than Object,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51346911/

相关文章:

android - 是否可以同时在 iOS 和 Android 模拟器上启用热重载?

android - Flutter 按住闪屏 3 秒。如何在 Flutter 中实现闪屏?

dart - Dart AOT 是如何工作的?

text - 如果文本溢出,则替换文本

dart - 如何将数据发布到 dart 中的 https 服务器?

asynchronous - Flutter Redux snackbar

visual-studio-code - 带有 VSCode 的 Flutter 显示未安装,即使已

dart - 使用 WidgetsApp 的应用导航示例

dart - 按下时更改 float 按钮图标的方法

flutter - 如何解决家庭酿造的 flutter 医生问题?