参数类型 '_ProfileImageState' 不能分配给参数类型 'TickerProvider'

问题描述

主要目标是允许用户从图库/相机中选择图像,但为了使图像看起来更好,使用了一些动画并设计了整个图像选择对话框

class _ProfileImageState extends State<ProfileImage>{

      @override

      File _image;

      //ImagePickerHandler imagePicker;

      @override
      void initState() {

        super.initState();
//initiating to start so that transition from one state to another is smooth
 
        var _controller = new AnimationController(
          vsync: this,duration: const Duration(milliseconds: 500),);


        imagePicker=new ImagePickerHandler(this.userImage(_image));


      }

解决方法

您需要使用 SingleTickerProviderStateMixin mixin 将其用作 vsyn c 参数。您可以通过使用 with 关键字来实现此目的

class _ProfileImageState extends State<ProfileImage> with SingleTickerProviderStateMixin {

      @override

      File _image;

      //ImagePickerHandler imagePicker;

      @override
      void initState() {

        super.initState();
 
        var _controller = new AnimationController(
          vsync: this,duration: const Duration(milliseconds: 500),);


        imagePicker=new ImagePickerHandler(this.userImage(_image));


      }```

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...