createSimulationDataSource static method
- Route route
Create a simulated data source from a Route.
The returned DataSource will simulate sensor data based on the provided route and can be used for testing or replay scenarios.
Usually simulation on a given route is done via the NavigationService.startSimulation method.
Parameters
route: The Route to simulate.
Returns
- DataSource?: A simulation data source, or null if creation failed.
Implementation
static DataSource? createSimulationDataSource(final Route route) {
final String resultString = GemKitPlatform.instance.callCreateObject(
jsonEncode(<String, Object>{
'class': 'DataSourceContainer',
'args': <String, dynamic>{
'type': 'simulation',
'routeId': route.pointerId,
},
}),
);
final dynamic decodedVal = jsonDecode(resultString);
final int gemApiError = decodedVal['gemApiError'];
if (GemErrorExtension.isErrorCode(gemApiError)) {
return null;
}
final DataSource retVal = DataSource.init(decodedVal['result']);
return retVal;
}