Здесь я пытаюсь загрузить csv-файл из хранилища Firebase в моем приложении-флаттере?
Future<void> _downloadFile(StorageReference ref,url) async {
final String uuid = Uuid().v1();
print(uuid);
final http.Response downloadData = await http.get(url);
print(downloadData.body);
final Directory systemTempDir = Directory.systemTemp;
print(systemTempDir);
Directory tempDir = await getTemporaryDirectory();
String tempPath = tempDir.path;
print(tempPath);
final File tempFile = File('${tempPath}/tmp$uuid.csv');
if (tempFile.existsSync()) {
await tempFile.delete();
}
await tempFile.create();
assert(await tempFile.readAsString() == "");
print(tempFile);
final StorageFileDownloadTask task = ref.writeToFile(tempFile);
final int byteCount = (await task.future).totalByteCount;
final String tempFileContents = await tempFile.readAsString();
final String fileContents = downloadData.body;
final String name = await ref.getName();
final String bucket = await ref.getBucket();
final String path = await ref.getPath();
print(fileContents);
}
Возвращает ошибку о том, что writeToFile был вызван для нуля.