toJson method
Converts this Connection to a JSON map.
This method serializes all connection properties, including observable values, to a JSON-compatible map.
Implementation
Map<String, dynamic> toJson() {
final json = _$ConnectionToJson(this);
// Include observable labels in JSON
if (_startLabel.value != null) {
json['startLabel'] = _startLabel.value!.toJson();
}
if (_label.value != null) {
json['label'] = _label.value!.toJson();
}
if (_endLabel.value != null) {
json['endLabel'] = _endLabel.value!.toJson();
}
// Include control points in JSON
if (_controlPoints.isNotEmpty) {
json['controlPoints'] = _controlPoints
.map((offset) => {'dx': offset.dx, 'dy': offset.dy})
.toList();
}
return json;
}