hasInputDevice method

Future<bool> hasInputDevice()

Checks if there is any available input device (microphone).

Returns true if there is at least one available input device, false if there is no available input device.

Example:

final hasDevice = await micCapture.hasInputDevice();
if (hasDevice) {
  print('Microphone available');
  await micCapture.startCapture();
} else {
  print('No microphone found');
}

Implementation

Future<bool> hasInputDevice() async {
  try {
    final hasDevice = await _channel.invokeMethod<bool>(
      _MicAudioMethod.hasInputDevice.name,
    );
    return hasDevice ?? false;
  } catch (e) {
    rethrow;
  }
}