Map<String, dynamic> toJson() { final unit = this.unit; final value = this.value; return { if (unit != null) 'unit': unit.toValue(), if (value != null) 'value': value, }; }