我运行了颤振的插件image_picker
示例。
当我从画廊中一张一张地挑选图像时,内存不断增加。理想情况下,memory should jump back
因为它at most select one image
在此示例应用程序中。
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.
...
}
}
我的问题是如何dispose the resource
使用File
?