93 lines
2.8 KiB
Dart
93 lines
2.8 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;
|
|
|
|
static const String _defaultSentryDsn = String.fromEnvironment(
|
|
'SENTRY_DSN',
|
|
defaultValue:
|
|
'https://97fb0a56bc35440fba0ba139dc3b1ccc@bugs.zuzo.ch/2',
|
|
);
|
|
|
|
static const String _defaultSentryEnvironment = String.fromEnvironment(
|
|
'SENTRY_ENVIRONMENT',
|
|
defaultValue: '',
|
|
);
|
|
|
|
static const String _defaultSentryRelease = String.fromEnvironment(
|
|
'SENTRY_RELEASE',
|
|
defaultValue: '',
|
|
);
|
|
|
|
/// 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: false);
|
|
|
|
/// Enables local notifications runtime for reminder delivery.
|
|
static bool get enableLocalNotifications => const bool.fromEnvironment(
|
|
'ENABLE_LOCAL_NOTIFICATIONS',
|
|
defaultValue: true,
|
|
);
|
|
|
|
/// Enables inbound share-intake pipeline for WhatsApp text shares.
|
|
static bool get enableWhatsAppShareIntake => const bool.fromEnvironment(
|
|
'ENABLE_WHATSAPP_SHARE_INTAKE',
|
|
defaultValue: true,
|
|
);
|
|
|
|
/// Interval used for periodic background sync ticks.
|
|
static int get backgroundSyncIntervalSeconds => const int.fromEnvironment(
|
|
'BACKGROUND_SYNC_INTERVAL_SECONDS',
|
|
defaultValue: 180,
|
|
);
|
|
|
|
/// Sentry-compatible DSN for release crash/error reporting.
|
|
static String get sentryDsn => _defaultSentryDsn.trim();
|
|
|
|
/// Sentry environment label.
|
|
static String get sentryEnvironment {
|
|
final String configured = _defaultSentryEnvironment.trim();
|
|
if (configured.isNotEmpty) {
|
|
return configured;
|
|
}
|
|
return useFakeBackend ? 'development' : 'production';
|
|
}
|
|
|
|
/// Optional Sentry release identifier.
|
|
static String? get sentryRelease {
|
|
final String configured = _defaultSentryRelease.trim();
|
|
if (configured.isEmpty) {
|
|
return null;
|
|
}
|
|
return configured;
|
|
}
|
|
|
|
/// Runtime override for backend URL (e.g. local settings screen).
|
|
static void overrideBackendBaseUrl(String? baseUrl) {
|
|
_baseUrlOverride = baseUrl;
|
|
}
|
|
}
|