FlutterCarplay constructor
FlutterCarplay()
Creates an FlutterCarplay and starts the connection.
Implementation
FlutterCarplay() {
_eventBroadcast = _carPlayController.eventChannel
.receiveBroadcastStream()
.listen((event) {
final FCPChannelTypes receivedChannelType = CPEnumUtils.enumFromString(
FCPChannelTypes.values,
event["type"],
);
switch (receivedChannelType) {
case FCPChannelTypes.onCarplayConnectionChange:
final CPConnectionStatusTypes connectionStatus =
CPEnumUtils.enumFromString(
CPConnectionStatusTypes.values,
event["data"]["status"],
);
_connectionStatus =
CPEnumUtils.stringFromEnum(connectionStatus.toString());
if (_onCarplayConnectionChange != null) {
_onCarplayConnectionChange!(connectionStatus);
}
break;
case FCPChannelTypes.onFCPListItemSelected:
_carPlayController
.processFCPListItemSelectedChannel(event["data"]["elementId"]);
break;
case FCPChannelTypes.onFCPAlertActionPressed:
_carPlayController
.processFCPAlertActionPressed(event["data"]["elementId"]);
break;
case FCPChannelTypes.onPresentStateChanged:
_carPlayController
.processFCPAlertTemplateCompleted(event["data"]["completed"]);
break;
case FCPChannelTypes.onGridButtonPressed:
_carPlayController
.processFCPGridButtonPressed(event["data"]["elementId"]);
break;
case FCPChannelTypes.onBarButtonPressed:
_carPlayController
.processFCPBarButtonPressed(event["data"]["elementId"]);
break;
case FCPChannelTypes.onTextButtonPressed:
_carPlayController
.processFCPTextButtonPressed(event["data"]["elementId"]);
break;
default:
break;
}
});
}