import 'package:json_annotation/json_annotation.dart'; import 'bean.dart'; import 'machine.dart'; import 'recipe.dart'; part 'drink.g.dart'; @JsonSerializable() class Drink { final String id; final String name; final String details; final String? image; final String notes; final bool preferred; final double rating; // 1-5 stars final String size; final Bean? bean; final Machine? machine; final Recipe? recipe; @JsonKey(fromJson: _dateTimeFromJson, toJson: _dateTimeToJson) final DateTime dateCreated; Drink({ required this.id, required this.name, required this.details, this.image, required this.notes, required this.preferred, required this.rating, required this.size, this.bean, this.machine, this.recipe, required this.dateCreated, }); factory Drink.fromJson(Map json) => _$DrinkFromJson(json); Map toJson() => _$DrinkToJson(this); static DateTime _dateTimeFromJson(String json) => DateTime.parse(json); static String _dateTimeToJson(DateTime dateTime) => dateTime.toIso8601String(); }