Refactor JSON Serialization in UpdateSpaceParam: Adjusted the _toJson method for Subspace to ensure 'subspaceName' is always included and 'uuid' is only added when applicable, enhancing clarity and consistency in data representation.

This commit is contained in:
Faris Armoush
2025-07-09 15:25:41 +03:00
parent 5cd083a37b
commit d87739f1fd

View File

@ -34,7 +34,8 @@ extension _SubspaceToJson on Subspace {
Map<String, dynamic> _toJson() { Map<String, dynamic> _toJson() {
final isNewSubspace = uuid.endsWith('-NewTag'); final isNewSubspace = uuid.endsWith('-NewTag');
return <String, dynamic>{ return <String, dynamic>{
if (isNewSubspace) 'subspaceName': name else 'uuid': uuid, if (!isNewSubspace) 'uuid': uuid,
'subspaceName': name,
'productAllocations': productAllocations.map((e) => e._toJson()).toList(), 'productAllocations': productAllocations.map((e) => e._toJson()).toList(),
}; };
} }