showAlert static method

Future<void> showAlert({
  1. required CPAlertTemplate template,
  2. bool animated = true,
})

It will present CPAlertTemplate modally.

  • template is to present modally.
  • If animated is true, CarPlay animates the presentation of the template.

! CarPlay can only present one modal template at a time.

Implementation

static Future<void> showAlert({
  required CPAlertTemplate template,
  bool animated = true,
}) {
  return _carPlayController.methodChannel.invokeMethod(
    EnumUtils.stringFromEnum(FCPChannelTypes.setAlert.toString()),
    <String, dynamic>{
      'rootTemplate': template.toJson(),
      'animated': animated,
      'onPresent': template.onPresent != null ? true : false,
    },
  ).then((value) {
    if (value) {
      FlutterCarPlayController.currentPresentTemplate = template;
    }
  });
}