【发布时间】:2022-12-24 23:11:34
【问题描述】:
'参数类型 'Uint8List?'无法分配给参数类型“Uint8List”
我试图将图像从 flutter web 应用程序上传到 firebase 存储,但代码中出现此错误。我该如何解决这个错误。代码如下:
`
``
Future<void> pickImage() async
{
FilePickerResult? result = await FilePicker.platform.pickFiles();
if (result != null) {
Uint8List? fileBytes =result.files.first.bytes;
String fileName = result.files.first.name;
setState(() {
fname=fileName;
});
// Upload file
await FirebaseStorage.instance.ref('images/$fileName').putData(fileBytes);
var Downloadurl=await FirebaseStorage.instance.ref('images/$fileName').getDownloadURL();
setState(() {
imgUrl=Downloadurl;
});
}
}
I tried html input element and image picker package too but cant solve the problem.
【问题讨论】:
标签: flutter firebase-storage flutter-web