push static method
Adds a template to the navigation hierarchy and displays it.
-
template is to add to the navigation hierarchy. Must be one of the type: CPGridTemplate or CPListTemplate CPInformationTemplate CPPointOfInterestTemplate If not, it will throw an TypeError
-
If animated is true, CarPlay animates the transition between templates.
Implementation
static Future<bool> push({
required CPTemplate template,
bool animated = true,
}) async {
if (template is CPGridTemplate ||
template is CPListTemplate ||
template is CPInformationTemplate ||
template is CPPointOfInterestTemplate) {
final bool? isCompleted =
await FlutterCarPlayController.flutterToNativeModule(
FCPChannelTypes.pushTemplate,
<String, dynamic>{
'template': template.toJson(),
'animated': animated,
},
);
if (isCompleted == true) {
_carPlayController.addTemplateToHistory(template);
}
return isCompleted ?? false;
} else {
throw TypeError();
}
}