fix : di for Role
This commit is contained in:
@@ -3,7 +3,6 @@ import 'package:rasadyar_chicken/data/di/chicken_di.dart';
|
||||
import 'package:rasadyar_chicken/presentation/routes/routes.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_core/data/model/local/target_page/target_page.dart';
|
||||
import 'package:rasadyar_core/hive_registrar.g.dart';
|
||||
import 'package:rasadyar_inspection/injection/inspection_di.dart';
|
||||
import 'package:rasadyar_inspection/inspection.dart';
|
||||
import 'package:rasadyar_livestock/injection/live_stock_di.dart';
|
||||
@@ -13,20 +12,20 @@ class LocalStorageService extends GetxService {
|
||||
static const String _targetPageBox = 'targetPageBox';
|
||||
|
||||
final HiveLocalStorage _localStorage = diCore.get<HiveLocalStorage>();
|
||||
late Box<TargetPage> _targetBox;
|
||||
|
||||
|
||||
Future<void> init() async {
|
||||
Hive.registerAdapters();
|
||||
await _localStorage.init();
|
||||
await _localStorage.openBox<TargetPage>(_targetPageBox);
|
||||
seedTargetPage();
|
||||
|
||||
}
|
||||
|
||||
Future<void> seedTargetPage() async {
|
||||
var existing = getTargetPage(null);
|
||||
if (existing == null) {
|
||||
_localStorage.addAll(
|
||||
_localStorage.addAll<TargetPage>(
|
||||
boxName: _targetPageBox,
|
||||
values: [
|
||||
values: <TargetPage>[
|
||||
TargetPage(
|
||||
route: InspectionRoutes.init,
|
||||
module: Module.inspection,
|
||||
@@ -59,24 +58,18 @@ class LocalStorageService extends GetxService {
|
||||
await _localStorage.add(boxName: _targetPageBox, value: targetPage);
|
||||
}
|
||||
|
||||
Iterable<Future?>? getFunctionsList(List<String>? functions) {
|
||||
return functions?.map((e) => getFunctionByName(e));
|
||||
Iterable<Future>? getFunctionsList(List<String>? functions) {
|
||||
return functions?.map((e) async => getFunctionByName(e));
|
||||
}
|
||||
|
||||
Future? getFunctionByName(String? name) {
|
||||
switch (name) {
|
||||
case "setupInspectionDI":
|
||||
return setupInspectionDI();
|
||||
case "removeInspectionDI":
|
||||
return removeInspectionDI();
|
||||
case "setupLiveStockDI":
|
||||
return setupLiveStockDI();
|
||||
case "removeLiveStockDI":
|
||||
return removeLiveStockDI();
|
||||
case "setupChickenDI":
|
||||
return setupChickenDI();
|
||||
case "removeChickenDI":
|
||||
return removeChickenDI();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user