Files
mobile/lib/core/config/app_config.dart

48 lines
1.5 KiB
Dart

import 'dart:io' show Platform;
import 'package:flutter/foundation.dart';
/// Surcharge explicite via `--dart-define=API_BASE_URL=...`
const String _envApiBaseUrl = String.fromEnvironment('API_BASE_URL');
/// URL de base de l'API Laverie.
///
/// Priorité :
/// 1. `API_BASE_URL` passé en `--dart-define`
/// 2. Valeur par défaut selon la plateforme :
/// - Android émulateur : `10.0.2.2` (localhost de l'hôte)
/// - iOS simulateur : `127.0.0.1`
/// 3. Appareil physique : toujours passer `--dart-define=API_BASE_URL=http://IP:8000/api/v1`
String get kApiBaseUrl {
if (_envApiBaseUrl.isNotEmpty) {
return _envApiBaseUrl;
}
if (kIsWeb) {
throw UnsupportedError('Le web Flutter n\'est pas supporté.');
}
if (Platform.isAndroid) {
return 'http://10.0.2.2:8000/api/v1';
}
if (Platform.isIOS) {
return 'http://127.0.0.1:8000/api/v1';
}
throw UnsupportedError('Plateforme non supportée.');
}
/// Clés de stockage sécurisé pour les jetons d'authentification.
abstract final class AuthStorageKeys {
static const accessToken = 'laverie_access_token';
static const refreshToken = 'laverie_refresh_token';
}
/// Clé publique Stripe (test) — surcharge via `--dart-define=STRIPE_PUBLISHABLE_KEY=...`
const String _envStripePublishableKey = String.fromEnvironment('STRIPE_PUBLISHABLE_KEY');
final String kStripePublishableKey = _envStripePublishableKey.isNotEmpty
? _envStripePublishableKey
: 'pk_test_51TpANRJRUgjTIwfBR9PoU4Lu201yD5R0JzvOv8Nmyva7ISX3GJPJ3IX4lSqnkg13siYwi3B9Qq0tIpEj6VCzeVFB00PSt9o0OA';