The argument type '_ProfileImageState' can't be assigned to the parameter type 'TickerProvider'

3.7k Views Asked by At

The main objective is to allow the user to choose an image from the gallery/camera but in order to make things look good some animation has been used and entire image picking dialogue box has been designed

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


      }
2

There are 2 best solutions below

0
er.arunkushwaha On BEST ANSWER

Extending SingleTickerProviderStateMixin fixed the issue:

class _ProfileImageState extends State with SingleTickerProviderStateMixin{

0
sid On

You need to use the SingleTickerProviderStateMixin mixin to use this as vsync param. You can achieve this by using with keyword here is how:

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


      }```