38 lines
1.9 KiB
Dart
38 lines
1.9 KiB
Dart
import 'package:get_it/get_it.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import 'core/constants/app_constants.dart';
|
|
import 'core/network/api_client.dart';
|
|
import 'core/storage/secure_storage.dart';
|
|
import 'core/services/tts_service.dart';
|
|
import 'core/services/stt_service.dart';
|
|
import 'core/services/voice_command_handler.dart';
|
|
import 'core/services/haptic_service.dart';
|
|
|
|
final sl = GetIt.instance;
|
|
|
|
Future<void> initDependencies() async {
|
|
// ── Core singletons ──────────────────────────────────────────────────────
|
|
sl.registerLazySingleton<SecureStorage>(() => SecureStorage());
|
|
sl.registerLazySingleton<ApiClient>(() => ApiClient(sl<SecureStorage>()));
|
|
|
|
sl.registerLazySingleton<TtsService>(() => TtsService());
|
|
sl.registerLazySingleton<SttService>(() => SttService());
|
|
sl.registerLazySingleton<HapticService>(() => HapticService());
|
|
sl.registerLazySingleton<VoiceCommandHandler>(
|
|
() => VoiceCommandHandler(sl<SttService>(), sl<TtsService>()),
|
|
);
|
|
|
|
// ── Init ApiClient if serverUrl already saved ─────────────────────────────
|
|
final serverUrl = await AppConstants.getServerUrl();
|
|
if (serverUrl != null && serverUrl.isNotEmpty) {
|
|
await sl<ApiClient>().init(serverUrl);
|
|
}
|
|
|
|
// ── Init TTS ──────────────────────────────────────────────────────────────
|
|
await sl<TtsService>().init();
|
|
|
|
// ── Init STT ──────────────────────────────────────────────────────────────
|
|
await sl<SttService>().init();
|
|
sl<VoiceCommandHandler>().loadDefaultCommands();
|
|
} |