update the app
This commit is contained in:
@@ -3,21 +3,39 @@ import 'dart:io';
|
||||
class AppConstants {
|
||||
static const String apiBaseUrlOverride =
|
||||
String.fromEnvironment('API_BASE_URL');
|
||||
static const String developmentAndroidApiUrl = 'http://10.0.2.2:4000/api/v1';
|
||||
static const String developmentLocalApiUrl = 'http://localhost:4000/api/v1';
|
||||
static const String dashboardUrlOverride =
|
||||
String.fromEnvironment('DASHBOARD_URL');
|
||||
|
||||
// Production
|
||||
static const String productionApiUrl = 'https://api.rentaldrivego.ma/api/v1';
|
||||
static const String productionDashboardUrl = 'https://rentaldrivego.ma/dashboard';
|
||||
|
||||
// Development
|
||||
static const String devAndroidApiUrl = 'http://10.0.2.2:4000/api/v1';
|
||||
static const String devLocalApiUrl = 'http://localhost:4000/api/v1';
|
||||
static const String devAndroidDashboardUrl = 'http://10.0.2.2:3001';
|
||||
static const String devLocalDashboardUrl = 'http://localhost:3001';
|
||||
|
||||
// Dev builds stay local by default. Real phones still need a LAN-reachable
|
||||
// override because their localhost is the phone itself, not the dev machine.
|
||||
static String get baseUrl {
|
||||
if (apiBaseUrlOverride.isNotEmpty) {
|
||||
return apiBaseUrlOverride;
|
||||
}
|
||||
if (apiBaseUrlOverride.isNotEmpty) return apiBaseUrlOverride;
|
||||
if (Platform.isAndroid) return devAndroidApiUrl;
|
||||
return devLocalApiUrl;
|
||||
}
|
||||
|
||||
if (Platform.isAndroid) {
|
||||
return developmentAndroidApiUrl;
|
||||
}
|
||||
static String get dashboardBaseUrl {
|
||||
if (dashboardUrlOverride.isNotEmpty) return dashboardUrlOverride;
|
||||
if (Platform.isAndroid) return devAndroidDashboardUrl;
|
||||
return devLocalDashboardUrl;
|
||||
}
|
||||
|
||||
return developmentLocalApiUrl;
|
||||
static String resolveMediaUrl(String url) {
|
||||
if (!url.startsWith('http')) {
|
||||
return '${baseUrl.replaceAll('/api/v1', '')}$url';
|
||||
}
|
||||
if (Platform.isAndroid && url.contains('localhost')) {
|
||||
return url.replaceFirst('localhost', '10.0.2.2');
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
static const String tokenKey = 'auth_token';
|
||||
|
||||
Reference in New Issue
Block a user