getMicrophones method Null safety

Future<List<AndroidMicrophoneInfo>> getMicrophones()

(UNTESTED) Requires API level 28

Implementation

Future<List<AndroidMicrophoneInfo>> getMicrophones() async {
  return ((await _channel.invokeListMethod<Map<String, dynamic>>(
          'getMicrophones')) as List<dynamic>)
      .map((raw) => AndroidMicrophoneInfo(
            description: raw['description'],
            id: raw['id'],
            type: raw['type'],
            address: raw['address'],
            location:
                decodeEnum(AndroidMicrophoneLocation.values, raw['location']),
            group: raw['group'],
            indexInTheGroup: raw['indexInTheGroup'],
            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'],
            maxSpl: raw['maxSpl'],
            minSpl: raw['minSpl'],
            directionality: decodeEnum(AndroidMicrophoneDirectionality.values,
                raw['directionality']),
          ))
      .toList();
}