You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
814 B
30 lines
814 B
import 'package:smartfit_app_mobile/objectbox.g.dart';
|
|
import 'package:path/path.dart' as p;
|
|
import 'package:path_provider/path_provider.dart';
|
|
import 'package:smartfit_app_mobile/modele/local_db/model.dart';
|
|
|
|
class ObjectBox {
|
|
late final Store store;
|
|
late final Box userBox;
|
|
late final Box activityBox;
|
|
|
|
ObjectBox._create(this.store);
|
|
|
|
static Future<ObjectBox> create() async {
|
|
final docsDir = await getApplicationDocumentsDirectory();
|
|
// Future<Store> openStore() {...} is defined in the generated objectbox.g.dart
|
|
final store =
|
|
await openStore(directory: p.join(docsDir.path, "obx-example"));
|
|
return ObjectBox._create(store);
|
|
}
|
|
|
|
init() {
|
|
userBox = store.box<User>();
|
|
activityBox = store.box<Activity>();
|
|
}
|
|
|
|
bool hasUser() {
|
|
return !userBox.isEmpty();
|
|
}
|
|
}
|