I run flutter's plugin image_picker
's sample.
When I pick image one by one from gallery, the memory keep increase. Ideally the memory should jump back
since it at most select one image
in this example app.
class _MyHomePageState extends State<MyHomePage> {
File _imageFile; <-- this one keep the file of selected image.
dynamic _pickImageError;
bool isVideo = false;
VideoPlayerController _controller;
String _retrieveDataError;
void _onImageButtonPressed(ImageSource source) async {
...
try {
_imageFile = await ImagePicker.pickImage(source: source); <--- how to set value
setState(() {});
} catch (e) {
_pickImageError = e;
}
...
}
@override
Widget build(BuildContext context) {
...
Image.file(_imageFile); <-- how to use it to display UI.
...
}
}
My question is how to dispose the resource
used by the File
?