我正在尝试使用图像选择器在抖动中使用相机获取图像,但出现错误
lib/Screen/AllDocuments.dart:15:3: Error: 'File' isn't a type.
File _image;
我也尝试过投放,但仍然无法正常工作
File _image;
final picker = ImagePicker();
Future getImage() async {
final pickedFile = await picker.getImage(source: ImageSource.camera);
setState(() {
_image = File(pickedFile);
});
}
如何解决此错误
答案 0 :(得分:2)
您必须在.path
上调用pickedFile
方法。
在此处查看此文档=> Image Picker
使用此:
File _image;
final picker = ImagePicker();
Future getImage() async {
final pickedFile = await picker.getImage(source: ImageSource.camera);
setState(() {
_image = File(pickedFile.path);
});
}