2021-11-07 20:13:28 +00:00
|
|
|
import 'package:diameter/main.dart';
|
|
|
|
import 'package:objectbox/objectbox.dart';
|
2021-10-22 23:08:09 +00:00
|
|
|
|
2021-11-09 00:17:35 +00:00
|
|
|
@Entity(uid: 3158200688796904913)
|
2021-10-22 23:08:09 +00:00
|
|
|
class MealCategory {
|
2021-11-07 20:13:28 +00:00
|
|
|
static final Box<MealCategory> box = objectBox.store.box<MealCategory>();
|
|
|
|
|
2021-11-26 23:01:12 +00:00
|
|
|
// properties
|
2021-11-07 20:13:28 +00:00
|
|
|
int id;
|
2021-11-26 23:01:12 +00:00
|
|
|
bool deleted;
|
2021-11-07 20:13:28 +00:00
|
|
|
String value;
|
|
|
|
String? notes;
|
|
|
|
|
2021-11-26 23:01:12 +00:00
|
|
|
// constructor
|
2021-11-07 20:13:28 +00:00
|
|
|
MealCategory({
|
|
|
|
this.id = 0,
|
2021-11-26 23:01:12 +00:00
|
|
|
this.deleted = false,
|
2021-11-07 20:13:28 +00:00
|
|
|
this.value = '',
|
|
|
|
this.notes,
|
|
|
|
});
|
|
|
|
|
2021-11-26 23:01:12 +00:00
|
|
|
// methods
|
2021-11-07 20:13:28 +00:00
|
|
|
static MealCategory? get(int id) => box.get(id);
|
|
|
|
static void put(MealCategory mealCategory) => box.put(mealCategory);
|
2021-11-26 23:01:12 +00:00
|
|
|
|
|
|
|
static List<MealCategory> getAll() => box.getAll();
|
|
|
|
|
|
|
|
static void remove(int id) {
|
|
|
|
final item = box.get(id);
|
|
|
|
if (item != null) {
|
|
|
|
item.deleted = true;
|
|
|
|
box.put(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() {
|
|
|
|
return value;
|
|
|
|
}
|
2021-10-22 23:08:09 +00:00
|
|
|
}
|