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