mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
This is now separated into individual tables and methods so that they can be tested separately
32 lines
803 B
Dart
32 lines
803 B
Dart
import 'dart:developer';
|
|
|
|
import 'package:get_it/get_it.dart';
|
|
import 'package:wger/database/exercises/exercise_database.dart';
|
|
import 'package:wger/database/ingredients/ingredients_database.dart';
|
|
|
|
final locator = GetIt.asNewInstance();
|
|
|
|
class ServiceLocator {
|
|
factory ServiceLocator() => _singleton;
|
|
|
|
ServiceLocator._internal();
|
|
|
|
static final ServiceLocator _singleton = ServiceLocator._internal();
|
|
|
|
Future<void> _initDB() async {
|
|
final exerciseDB = ExerciseDatabase();
|
|
final ingredientDB = IngredientDatabase();
|
|
locator.registerSingleton<ExerciseDatabase>(exerciseDB);
|
|
locator.registerSingleton<IngredientDatabase>(ingredientDB);
|
|
}
|
|
|
|
Future<void> configure() async {
|
|
try {
|
|
await _initDB();
|
|
} catch (e, _) {
|
|
log(e.toString());
|
|
rethrow;
|
|
}
|
|
}
|
|
}
|