
[英]A value of type 'XFIle' can't be assigned to a variable of type 'File' error
[英]A value of type 'XFile' can't be assigned to a variable of type File
我的源代码产生了两个错误:
这是我的源代码:
`
String _tweetText;
File _pickedImage;
bool _loading = false;
handleImageFromGallery() async {
try {
File imageFile = await ImagePicker.pickImage(source: ImageSource.gallery);
if (imageFile != null) {
setState(() {
_pickedImage = imageFile;
});
}
} catch (e) {
print(e);
}
}
`
我是 flutter 的新手,到目前为止无法解决这些问题。
要解决最重要的问题,请编写此代码
fileVar=File(XfileVar)
要解决第二个问题,您必须将变量分配给 _pickedImage 或通过添加使其成为 null ?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.