Refactor code structure for improved readability and maintainability

This commit is contained in:
Achintha Isuru
2026-03-09 16:26:53 -04:00
parent 7a5c130289
commit 2484c6cff2
38 changed files with 5894 additions and 309 deletions

View File

@@ -9,6 +9,7 @@ export 'src/presentation/widgets/web_mobile_frame.dart';
export 'src/presentation/mixins/bloc_error_handler.dart';
export 'src/presentation/observers/core_bloc_observer.dart';
export 'src/config/app_config.dart';
export 'src/config/app_environment.dart';
export 'src/routing/routing.dart';
export 'src/services/api_service/api_service.dart';
export 'src/services/api_service/dio_client.dart';

View File

@@ -0,0 +1,46 @@
/// Represents the application environment.
enum AppEnvironment {
dev,
stage,
prod;
/// Resolves the current environment from the compile-time `ENV` dart define.
/// Defaults to [AppEnvironment.dev] if not set or unrecognized.
static AppEnvironment get current {
const String envString = String.fromEnvironment('ENV', defaultValue: 'dev');
return AppEnvironment.values.firstWhere(
(AppEnvironment e) => e.name == envString,
orElse: () => AppEnvironment.dev,
);
}
/// Whether the app is running in production.
bool get isProduction => this == AppEnvironment.prod;
/// Whether the app is running in a non-production environment.
bool get isNonProduction => !isProduction;
/// The Firebase project ID for this environment.
String get firebaseProjectId {
switch (this) {
case AppEnvironment.dev:
return 'krow-workforce-dev';
case AppEnvironment.stage:
return 'krow-workforce-staging';
case AppEnvironment.prod:
return 'krow-workforce-prod';
}
}
/// A display label for the environment (empty for prod).
String get label {
switch (this) {
case AppEnvironment.dev:
return '[DEV]';
case AppEnvironment.stage:
return '[STG]';
case AppEnvironment.prod:
return '';
}
}
}