push static method

Future<bool> push({
  1. required AATemplate template,
})

Removes a modal template. Since CPAlertTemplate and CPActionSheetTemplate are both modals, they can be removed. If animated is true, CarPlay animates the transition between templates. Adds a template to the navigation hierarchy and displays it.

  • template is to add to the navigation hierarchy. Must be one of the type: AAGridTemplate or AAListTemplate AAInformationTemplat AAPointOfInterestTemplate

Be aware of the restrictions : https://developer.android.com/training/cars/apps#template-restrictions

  • Max 5 templates in the navigation stack.

Implementation

/* static Future<bool> popModal({bool animated = true}) async {
  FlutterCarPlayController.currentPresentTemplate = null;
  return await _androidAutoController.flutterToNativeModule(
    FAAChannelTypes.closePresent,
    animated,
  );
}*/

/// Adds a template to the navigation hierarchy and displays it.
///
/// - template is to add to the navigation hierarchy. **Must be one of the type:**
/// [AAGridTemplate] or [AAListTemplate] [AAInformationTemplat] [AAPointOfInterestTemplate]
///
/// Be aware of the restrictions : https://developer.android.com/training/cars/apps#template-restrictions
/// - Max 5 templates in the navigation stack.
static Future<bool> push({
  required AATemplate template,
}) async {
  final bool? isCompleted = await _androidAutoController
      .flutterToNativeModule(FAAChannelTypes.pushTemplate, <String, dynamic>{
    'template': template.toJson(),
    'runtimeType': 'F${template.runtimeType}',
  });
  if (isCompleted == true) {
    FlutterAndroidAutoController.templateHistory.add(template);
  }
  return isCompleted ?? false;
}