0

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

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));


      }
4

1 回答 1

2

您需要使用SingleTickerProviderStateMixinmixin 来this用作 vsync 参数。您可以通过使用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));


      }```
于 2021-07-13T10:20:37.257 回答