diameter/lib/models/meal_category.dart

41 lines
807 B
Dart

import 'package:diameter/main.dart';
import 'package:objectbox/objectbox.dart';
@Entity(uid: 3158200688796904913)
class MealCategory {
static final Box<MealCategory> box = objectBox.store.box<MealCategory>();
// 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<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;
}
}