setSyncBodyBuilder static method
- SyncBodyBuilder? builder
Sets a callback to build custom HTTP sync body.
When set, this callback is invoked before each sync request. The returned Map is used as the HTTP request body instead of the default location array format.
This is useful for backends that require a specific JSON structure.
Example (WeOrbis-style envelope):
Locus.setSyncBodyBuilder((locations, extras) async {
return {
'ownerId': extras['ownerId'],
'taskId': extras['taskId'],
'polygons': locations.map((l) => {
'lat': l.coords.latitude,
'lng': l.coords.longitude,
'timestamp': l.timestamp.toIso8601String(),
}).toList(),
};
});
Implementation
static void setSyncBodyBuilder(SyncBodyBuilder? builder) {
_instance.setSyncBodyBuilder(builder);
}