createLiveDataSource static method
DataSource?
createLiveDataSource({
- ImproveMode improveMode = ImproveMode.sensorFusionWithMapMatching,
Create a new live data source.
Creates a DataSource backed by live sensors. Use this when you need real-time sensor updates from the device.
Requires appropriate permissions to access device sensors.
Parameters
improveMode: Specifies how raw sensor data is processed to generate an improved position estimate (e.g., sensor fusion or dead reckoning). The selected mode affects the internal processing pipeline applied on incoming data. Defaults to ImproveMode.sensorFusionWithMapMatching.
Returns
- DataSource: The created live source, owned by the caller: drive it with start and
stop, and release it with
dispose. null: The engine could not produce a live source. The underlying GemError is not surfaced.
Implementation
static DataSource? createLiveDataSource({
ImproveMode improveMode = ImproveMode.sensorFusionWithMapMatching,
}) {
final String resultString = GemKitPlatform.instance.callCreateObject(
jsonEncode(<String, Object>{
'class': 'DataSourceContainer',
'args': <String, Object>{'type': 'live', 'improveMode': improveMode.id},
}),
);
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;
}