This is driving me nuts. I am trying to record an audio file and upload it to firebase. I used the information provided by Dimitar (thank you!!) but as others have mentioned, the solution offered there is not working on IOS. I am able to get to a fully functional solution on Android but for some reason, cant get the file on IOS.
The issue is not the Firebase upload, but rather accessing the file itself on IOS.
The specific relevant code is:
path = await _audioRecorder.stop(); //path returned is indeed NOT NULL
Uint8List? bytes = await getUint8ListFromLocalPath(path);
Future<Uint8List?> getUint8ListFromLocalPath(String? localPath) async {
if (localPath == null || localPath.isEmpty) {
return null;
}
try {
final file = File(localPath);
return await file.readAsBytes();
} catch (e) {
print('Error reading file: $e'); return null;
}
}
On android it is working well, on IOS there seems to be an issue with the file location. I dont think it is a permissions issue as I am able to play the audio file by using:
await player.play(DeviceFileSource(path!));