showVoiceControl static method

Future<bool> showVoiceControl({
  1. required CPVoiceControlTemplate template,
  2. bool animated = true,
})

Presents a voice indicator modally and returns the native presentation result.

Returns false if disconnected, cancelled or another modal is pending/open. Invalid native inputs and unsupported controls throw PlatformException. The app's approved category must support this template. This method does not request microphone permission, record audio or start Siri.

Implementation

static Future<bool> showVoiceControl({
  required CPVoiceControlTemplate template,
  bool animated = true,
}) async {
  if (defaultTargetPlatform != TargetPlatform.iOS ||
      _connectionStatus == ConnectionStatusTypes.disconnected.name) {
    return false;
  }
  return FlutterCarPlayController.presentModal(
    template,
    FCPChannelTypes.setVoiceControlTemplate,
    {'template': template.toJson(), 'animated': animated},
  );
}