Minimal Code:
File _file;
Future _pickImage() async {
final image = await ImagePicker.pickImage(source: ImageSource.camera);
i
you need 3 things:
first you have to use ImageProvider
and its evict()
method:
var image = FileImage(File('someImage.jpg'));
then you need Image
widget that uses above ImageProvider
and also assigns a unique key
in order to be "different" each time build()
method is called:
child: Image(
image: image,
key: UniqueKey(),
),
and finally after you overwrite someImage.jpg
you have to call evict()
method:
// part of your _pickImage() method
// here someImage.jpg contains updated content
image.evict();
setState(() {});
UPDATE: actually you dont need var image = FileImage(File('someImage.jpg'));
- you can use it directly inside Image
widget as image: FileImage(File('someImage.jpg'))
and call FileImage(File('someImage.jpg')).evict()
after your image is ovewritten