Integration with CarPlay and Android Auto
Currently, the Flutter platform provides no direct support for Apple's CarPlay, Android Auto and Android Automotive.
NotePlease note that while Android Auto, Android Automotive and CarPlay may function as expected, their compatibility is not guaranteed, as these dependencies are neither managed nor tested by the HERE SDK team.
If you are interested how CarPlay and Android Auto can be implemented with the native HERE SDK variants, take a look below:
-
Flutter allows to write custom platform-specific code using method channels.
-
Add support for CarPlay using the HERE SDK for iOS: Follow the Integrate a HERE Map into CarPlay tutorial to see how you can get started and show a map view on a car's head unit display.
-
Add support for Android Auto using the HERE SDK for Android: If you want to show a map view on the Desktop Head Unit, you need to render the map using a
MapSurfaceinstance. Follow the Integrate a HERE Map into Android Auto tutorial to see how this can be done.
The native SDKs for iOS and Android are already included as part of the Flutter plugin folder that comes bundled with the HERE SDK for Flutter download package. However, when you are trying to access native code, you need to integrate the Here SDK: for example, on Android you need to add the name of the AAR as it appears in the plugin folder in your app's build.gradle file. Similar steps for iOS are needed. Then you can access the native HERE SDK APIs from Java, Kotlin or Swift source files.
In order to simplify the map view handling a bit, you can access the following native classes MapSurfaceHost.kt, MapViewHost.kt and MapViewHost.swift that are part of the HERE SDK. With these host classes for each native view, e.g. MapView in Swift and MapSurface in Java, you can control the native view through a HereMapController from Dart side.
Usage example for Java:
import com.here.sdk.mapview.MapSurface;
import com.here.sdk.mapview.MapSurfaceHost;
...
MapSurfaceHost surfaceHost = new MapSurfaceHost(123, flutterEngine.getDartExecutor().getBinaryMessenger(), mapSurface);
Usage exampe for Swift:
import heresdk
import here_sdk
...
let mapViewHost = MapViewHost(viewIdentifier: 123,
binaryMessenger: FlutterBinaryMessenger,
mapView: MapView)
Then on Dart side, use the same view ID - "123" for example:
methodChannel.setMethodCallHandler((call) async {
if (call.method == 'mapCreated') {
print('ExampleApp - map surface created');
HereMapController mapSurfaceController = HereMapController(123);
bool success = await mapSurfaceController.initialize((event) {});
if (!success) {
print('ExampleApp -Failed to initialize controller');
return;
}
mapSurfaceController.mapScene.loadSceneForMapScheme(MapScheme.normalNight, (MapError? error) {
...
});
}Note that this does not include any Android Auto or CarPlay functionality. As of now, the created surface will be non-responsive to any gesture - even if there is a touch display available in-car.
Updated yesterday