【发布时间】:2021-11-06 00:07:32
【问题描述】:
我在代码下方尝试过,但遇到了问题:
未处理的异常:空值检查运算符用于空值
FirebaseStorage storage = FirebaseStorage.instance;
FilePickerResult? result = await FilePicker.platform.pickFiles(
type: FileType.custom,
allowedExtensions: ['pdf'],
withData: true
);
if (result != null) {
Uint8List? fileBytes = result.files.first.bytes;
String fileName = result.files.first.name;
// Upload PDF file
TaskSnapshot taskSnapshot = await storage.ref('CV/$fileName').putData(fileBytes!);
String pdfUrl = await taskSnapshot.ref.getDownloadURL();
print('pdf url: $pdfUrl');
}
【问题讨论】: