convertToWav method

  1. @override
Future<String> convertToWav(
  1. String inputPath,
  2. String outputPath, {
  3. int? sampleRate,
  4. int? channels,
  5. int? bitDepth,
})
override

Implementation

@override
Future<String> convertToWav(
  String inputPath,
  String outputPath, {
  int? sampleRate,
  int? channels,
  int? bitDepth,
}) async {
  try {
    final args = <String, dynamic>{
      'inputPath': inputPath,
      'outputPath': outputPath,
    };
    if (sampleRate != null) args['sampleRate'] = sampleRate;
    if (channels != null) args['channels'] = channels;
    if (bitDepth != null) args['bitDepth'] = bitDepth;
    final result = await methodChannel.invokeMethod<String>(
      'convertToWav',
      args,
    );
    if (result == null) {
      throw AudioConversionException('Native conversion returned null');
    }
    return result;
  } on PlatformException catch (e) {
    throw AudioConversionException(
      e.message ?? 'Unknown conversion error',
      details: e.details?.toString(),
    );
  }
}