factory Scale.fromJson(Map<String, dynamic> json) { return Scale( unit: (json['unit'] as String?)?.toScaleUnit(), value: json['value'] as double?, ); }