50 lines
1.6 KiB
Dart
50 lines
1.6 KiB
Dart
/// Application-level runtime configuration.
|
|
class AppConfig {
|
|
AppConfig._();
|
|
|
|
static const String _defaultBaseUrl = String.fromEnvironment(
|
|
'BACKEND_BASE_URL',
|
|
defaultValue: 'https://api.example.com',
|
|
);
|
|
|
|
static String? _baseUrlOverride;
|
|
|
|
/// Returns the configured backend base URL.
|
|
static String get backendBaseUrl {
|
|
final String? override = _baseUrlOverride;
|
|
if (override != null && override.trim().isNotEmpty) {
|
|
return override.trim();
|
|
}
|
|
return _defaultBaseUrl;
|
|
}
|
|
|
|
/// Enables fake backend implementation for local/offline development.
|
|
static bool get useFakeBackend =>
|
|
const bool.fromEnvironment('USE_FAKE_BACKEND', defaultValue: true);
|
|
|
|
/// Enables Hive local persistence store instead of shared_preferences.
|
|
static bool get useHiveLocalDb =>
|
|
const bool.fromEnvironment('USE_HIVE_LOCAL_DB', defaultValue: true);
|
|
|
|
/// Enables periodic startup/resume sync triggers while authenticated.
|
|
static bool get enableBackgroundSync =>
|
|
const bool.fromEnvironment('ENABLE_BACKGROUND_SYNC', defaultValue: true);
|
|
|
|
/// Enables local notifications runtime for reminder delivery.
|
|
static bool get enableLocalNotifications => const bool.fromEnvironment(
|
|
'ENABLE_LOCAL_NOTIFICATIONS',
|
|
defaultValue: true,
|
|
);
|
|
|
|
/// Interval used for periodic background sync ticks.
|
|
static int get backgroundSyncIntervalSeconds => const int.fromEnvironment(
|
|
'BACKGROUND_SYNC_INTERVAL_SECONDS',
|
|
defaultValue: 180,
|
|
);
|
|
|
|
/// Runtime override for backend URL (e.g. local settings screen).
|
|
static void overrideBackendBaseUrl(String? baseUrl) {
|
|
_baseUrlOverride = baseUrl;
|
|
}
|
|
}
|