- Correction mapping JSON membres (fk_role, chk_active) - Ajout traitement amicale au login - Fix callback onSubmit pour sync Hive après update API
68 lines
2.1 KiB
Dart
68 lines
2.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter/foundation.dart' show kIsWeb;
|
|
import 'package:flutter_web_plugins/url_strategy.dart';
|
|
import 'package:geosector_app/core/services/app_info_service.dart';
|
|
import 'package:geosector_app/core/services/api_service.dart';
|
|
import 'package:geosector_app/app.dart';
|
|
import 'package:hive_flutter/hive_flutter.dart';
|
|
import 'package:geosector_app/core/services/hive_adapters.dart';
|
|
|
|
void main() async {
|
|
// IMPORTANT: Configurer l'URL strategy pour éviter les # dans les URLs
|
|
usePathUrlStrategy();
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
// Initialiser les services essentiels
|
|
await _initializeServices();
|
|
|
|
// Initialiser Hive avec gestion des erreurs
|
|
await _initializeHive();
|
|
|
|
// Configurer l'orientation de l'application (mobile uniquement)
|
|
if (!kIsWeb) {
|
|
await SystemChrome.setPreferredOrientations([
|
|
DeviceOrientation.portraitUp,
|
|
DeviceOrientation.portraitDown,
|
|
]);
|
|
}
|
|
|
|
// Lancer l'application
|
|
runApp(const GeosectorApp());
|
|
}
|
|
|
|
/// Initialise les services essentiels
|
|
Future<void> _initializeServices() async {
|
|
try {
|
|
// Initialiser ApiService en premier
|
|
await ApiService.initialize();
|
|
debugPrint('✅ ApiService singleton initialisé');
|
|
|
|
// Les services CurrentUserService et CurrentAmicaleService s'initialisent automatiquement
|
|
// au premier accès via le pattern singleton lazy
|
|
debugPrint('✅ CurrentUserService prêt');
|
|
debugPrint('✅ CurrentAmicaleService prêt');
|
|
|
|
await AppInfoService.initialize();
|
|
debugPrint('✅ Tous les services initialisés avec succès');
|
|
} catch (e) {
|
|
debugPrint('❌ Erreur lors de l\'initialisation des services: $e');
|
|
rethrow; // Important pour arrêter l'app si les services critiques échouent
|
|
}
|
|
}
|
|
|
|
Future<void> _initializeHive() async {
|
|
try {
|
|
await Hive.initFlutter();
|
|
|
|
// Enregistrer tous les adapters
|
|
HiveAdapters.registerAll();
|
|
|
|
debugPrint('✅ Hive et TypeAdapters initialisés');
|
|
} catch (e) {
|
|
debugPrint('❌ Erreur Hive: $e');
|
|
rethrow;
|
|
}
|
|
}
|