import 'package:diameter/main.dart'; import 'package:diameter/objectbox.g.dart'; @Entity() class BolusProfile { static final Box box = objectBox.store.box(); int id; String name; bool active; String? notes; BolusProfile({ this.id = 0, this.name = '', this.active = false, this.notes, }); static BolusProfile? get(int id) => box.get(id); static List getAll() => box.getAll(); static void put(BolusProfile bolusProfile) => box.put(bolusProfile); static void remove(int id) => box.remove(id); static int activeCount() { Query query = box.query(BolusProfile_.active.equals(true)).build(); return query.find().length; } static void setAllInactive() { box.putMany(box.getAll().map((element) { element.active = false; return element; }).toList()); } }