/// Environnements de déploiement de l'application enum Environment { dev, staging, prod } /// Configuration centralisée par environnement. /// Les URLs sont injectées via --dart-define=ENV=dev|staging|prod class AppConfig { static late final Environment _environment; static late final String apiBaseUrl; static late final String keycloakBaseUrl; static late final String wsBaseUrl; static late final bool enableDebugMode; static late final bool enableLogging; static late final bool enableCrashReporting; static late final bool enableAnalytics; /// Initialise la configuration à partir de l'environnement. /// Appeler dans main() avant runApp(). static void initialize() { const envString = String.fromEnvironment('ENV', defaultValue: 'dev'); _environment = Environment.values.firstWhere( (e) => e.name == envString, orElse: () => Environment.dev, ); switch (_environment) { case Environment.dev: apiBaseUrl = const String.fromEnvironment( 'API_URL', defaultValue: 'http://localhost:8085', ); keycloakBaseUrl = const String.fromEnvironment( 'KEYCLOAK_URL', defaultValue: 'http://localhost:8180', ); wsBaseUrl = const String.fromEnvironment( 'WS_URL', defaultValue: 'ws://localhost:8085', ); enableDebugMode = true; enableLogging = true; enableCrashReporting = false; enableAnalytics = false; case Environment.staging: apiBaseUrl = const String.fromEnvironment( 'API_URL', defaultValue: 'https://api-staging.lions.dev', ); keycloakBaseUrl = const String.fromEnvironment( 'KEYCLOAK_URL', defaultValue: 'https://security-staging.lions.dev', ); wsBaseUrl = const String.fromEnvironment( 'WS_URL', defaultValue: 'wss://api-staging.lions.dev', ); enableDebugMode = false; enableLogging = true; enableCrashReporting = true; enableAnalytics = false; case Environment.prod: apiBaseUrl = const String.fromEnvironment( 'API_URL', defaultValue: 'https://api.lions.dev', ); keycloakBaseUrl = const String.fromEnvironment( 'KEYCLOAK_URL', defaultValue: 'https://security.lions.dev', ); wsBaseUrl = const String.fromEnvironment( 'WS_URL', defaultValue: 'wss://api.lions.dev', ); enableDebugMode = false; enableLogging = false; enableCrashReporting = true; enableAnalytics = true; } } static Environment get environment => _environment; static bool get isDev => _environment == Environment.dev; static bool get isStaging => _environment == Environment.staging; static bool get isProd => _environment == Environment.prod; /// URL complète du realm Keycloak static String get keycloakRealmUrl => '$keycloakBaseUrl/realms/unionflow'; /// URL du endpoint token Keycloak static String get keycloakTokenUrl => '$keycloakRealmUrl/protocol/openid-connect/token'; /// URL du endpoint WebSocket dashboard static String get wsDashboardUrl => '$wsBaseUrl/ws/dashboard'; }