Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

type 'Image' is not a subtype of type 'ImageProvider<Object>' in type cast

I'm using the image picker in flutter and trying to get the image. Before I select the image it appear like this:

Before Upload Image

enter image description here

After Upload Image

enter image description here

here is the code:

backgroundImage: _pickedImage != null
          ? Image.file(_pickedImage!) as ImageProvider
          : const AssetImage('assets/images/profile-icon.png'),

How should solve this error?

Updated Error

enter image description here

https://codeshare.io/oQpBvX

like image 388
kiku Avatar asked Oct 16 '25 22:10

kiku


1 Answers

Use FileImage instead like so:

backgroundImage: _pickedImage != null
          ? FileImage(_pickedImage!)
          : const AssetImage('assets/images/profile-icon.png'),
like image 194
Josteve Avatar answered Oct 19 '25 12:10

Josteve



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!