Map<String, dynamic> toJson() { return { 'previousRect': previousRect.toJson(), 'currentRect': currentRect.toJson(), if (nodeId != null) 'nodeId': nodeId!.toJson(), }; }