initFile method

Future<void> initFile(
  1. String filename, {
  2. int sampleRate = 44100,
  3. int channels = 1,
  4. SoundFormat format = SoundFormat.f32,
})

Initializes the recorder to save to a file.

Implementation

Future<void> initFile(
  String filename, {
  int sampleRate = 44100,
  int channels = 1,
  SoundFormat format = SoundFormat.f32,
}) async {
  if (sampleRate <= 0 || channels <= 0) {
    throw ArgumentError("Invalid recorder parameters");
  }
  if (!_isInit) {
    await _recorder.initFile(
      filename,
      sampleRate: sampleRate,
      channels: channels,
      format: format,
    );

    _isInit = true;
  }
}