41 lines
1.1 KiB
Dart
41 lines
1.1 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';
|
|
}
|