kavx
kavx

Reputation: 77

PickedFile' can't be assigned to the parameter type 'File' error

Im trying to make an app that will open the camera and take a photo and load it using flutter. First I used pickImage but I got this message 'pickImage' is deprecated and shouldn't be used. Use imagePicker.getImage() method instead..

so I used getImage method...

_openCamera(BuildContext context) async{
var picture =await ImagePicker().getImage(source: ImageSource.camera);
this.setState(() {
  imageFile= picture;
});

but then this error came when I used the below code The argument type 'PickedFile' can't be assigned to the parameter type 'File'.

 if(imageFile==null){
  return Text("No selected Image");
}else{
  Image.file(imageFile,width: 400,height: 400);
}

Please help me .I'm very new to flutter

Upvotes: 0

Views: 1608

Answers (1)

osaxma
osaxma

Reputation: 2984

PickedFile, which is the type returned by imagePicker, is a type specific to image_picker package, hence it's not the same as File.

You can do the following to convert it to File:

Image.file(File(imageFile.path), width: 400, height: 400);

Upvotes: 1

Related Questions