PathNotFoundException when using record package in Flutter on iOS Simulator #433
Unanswered
Nikunj-Flutter
asked this question in
Q&A
Replies: 1 comment
-
I guess you are still in version 4. Output path is given from stop method. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am encountering an issue while using the record package in my Flutter app for audio recording. After starting and stopping the recording, I am getting a
PathNotFoundException
when trying to access the file at the path returned byrecord.stop()
. The error message is:Unhandled Exception: PathNotFoundException: Cannot open file, path = 'file:///Users/nikunj/Library/Developer/CoreSimulator/Devices/235B6666-3DAB-4CAF-B700-8134141DEA55/data/Containers/Data/Application/4BDB8CA2-82B3-4456-8D05-5E60D4CA8AFF/tmp/5F15A7DF-CD15-4843-A1AA-B6602393EA99.m4a' (OS Error: No such file or directory, errno = 2)
Code:
`Future startRecording() async {
await record.start();
}
Future stopAudio() async {
final path = await record.stop();
if (path == null) {
print("Error: Recording path is null.");
return;
}
final tempDir = await getTemporaryDirectory();
final filePath = '${tempDir.path}/audio-${DateTime.now().millisecondsSinceEpoch}.wav';
final file = File(filePath);
// Check if file exists before proceeding
if (!file.existsSync()) {
print("Error: File does not exist at $filePath");
return;
}
final bytes = await file.readAsBytes();
final base64Audio = base64Encode(bytes);
// Send the audio as needed
print("Audio ready to be sent.");
}
`
record
package to record audio in a Flutter app.record.stop()
, I am trying to save the file in the temporary directory.PathNotFoundException
error, even though I can see the file path looks correct.Beta Was this translation helpful? Give feedback.
All reactions