import 'package:diameter/main.dart'; import 'package:objectbox/objectbox.dart'; import 'package:diameter/objectbox.g.dart' show MealCategory_; @Entity(uid: 3158200688796904913) @Sync() class MealCategory { static final Box box = objectBox.store.box(); // properties int id; bool deleted; String value; String? notes; // constructor MealCategory({ this.id = 0, this.deleted = false, this.value = '', this.notes, }); // methods static MealCategory? get(int id) => box.get(id); static void put(MealCategory mealCategory) => box.put(mealCategory); static List getAll() { QueryBuilder builder = box.query(MealCategory_.deleted.equals(false))..order(MealCategory_.value); return builder.build().find(); } static void remove(int id) { final item = box.get(id); if (item != null) { item.deleted = true; box.put(item); } } @override String toString() { return value; } }