getMicrophones method

Future<List<AndroidMicrophoneInfo>> getMicrophones()

(UNTESTED) Requires API level 28

Implementation

Future<List<AndroidMicrophoneInfo>> getMicrophones() async {
  return ((await _channel
          .invokeListMethod<Map<dynamic, dynamic>>('getMicrophones'))!)
      .map((raw) => raw.cast<String, dynamic>())
      .map((raw) => AndroidMicrophoneInfo(
            description: raw['description'] as String,
            id: raw['id'] as int,
            type: raw['type'] as int,
            address: raw['address'] as String,
            location: decodeEnum(
                AndroidMicrophoneLocation.values, raw['location'] as int?,
                defaultValue: AndroidMicrophoneLocation.unknown),
            group: raw['group'] as int,
            indexInTheGroup: raw['indexInTheGroup'] as int,
            position: (raw['position'] as List<dynamic>).cast<double>(),
            orientation: (raw['orientation'] as List<dynamic>).cast<double>(),
            frequencyResponse: (raw['frequencyResponse'] as List<dynamic>)
                .map((dynamic item) => (item as List<dynamic>).cast<double>())
                .toList(),
            channelMapping: (raw['channelMapping'] as List<dynamic>)
                .map((dynamic item) => (item as List<dynamic>).cast<int>())
                .toList(),
            sensitivity: raw['sensitivity'] as double,
            maxSpl: raw['maxSpl'] as double,
            minSpl: raw['minSpl'] as double,
            directionality: decodeEnum(AndroidMicrophoneDirectionality.values,
                raw['directionality'] as int?,
                defaultValue: AndroidMicrophoneDirectionality.unknown),
          ))
      .toList();
}