Few points I noticed are
- Please check if its initialised or not in the initstate
await recorder.initialized;
//after initialisation add this
var current = await recorder.current(channel: 0);
//you should get the current status as initialised if its done properly.
- then on start recording use
await recorder.start()
Also make sure that the file path is right
Edit
This is the code to init the recorder
_init() async {
try {
bool hasPermission = await FlutterAudioRecorder2.hasPermissions ?? false;
if (hasPermission) {
String customPath = '/flutter_audio_recorder_';
io.Directory appDocDirectory;
// io.Directory appDocDirectory = await getApplicationDocumentsDirectory();
if (io.Platform.isIOS) {
appDocDirectory = await getApplicationDocumentsDirectory();
} else {
appDocDirectory = (await getExternalStorageDirectory())!;
}
// can add extension like ".mp4" ".wav" ".m4a" ".aac"
customPath = appDocDirectory.path + customPath + DateTime.now().millisecondsSinceEpoch.toString();
_recorder = FlutterAudioRecorder2(customPath, audioFormat: AudioFormat.AAC);
await _recorder!.initialized;
// after initialization
var current = await _recorder!.current(channel: 0);
print(current);
// should be "Initialized", if all working fine
} else {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text("You must accept permissions")));
}
} catch (e) {
print(e);
}
}