Флаттер — Аудиофайл сохраняется, но всегда составляет 0 байт

#flutter #dart #audio #storage

Вопрос:

Я сохраняю аудиофайл с этим кодом:

   void _createFile() async {
     var _completeFileName = await generateFileName();
     File(_directoryPath   '/'   _completeFileName)
    .create(recursive: true)
    .then((File file) async {
       //write to file
    Uint8List bytes = await file.readAsBytes();
    file.writeAsBytes(bytes);
    print(file.path);
 });
}
 

Файл сохраняется, но в нем нет данных. Он всегда равен 0B и, следовательно, не может быть воспроизведен.