- API 클라이언트 및 인증 인터셉터 에러 처리 강화 - 의존성 주입 실패 시에도 앱 실행 가능하도록 개선 - 사용하지 않는 레거시 UI 컴포넌트 및 화면 제거 - pubspec.yaml 의존성 업데이트 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
70 lines
1.8 KiB
Dart
70 lines
1.8 KiB
Dart
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
|
|
|
/// 환경 설정 관리 클래스
|
|
class Environment {
|
|
static const String dev = 'development';
|
|
static const String prod = 'production';
|
|
|
|
static late String _environment;
|
|
|
|
/// 현재 환경
|
|
static String get current => _environment;
|
|
|
|
/// 개발 환경 여부
|
|
static bool get isDevelopment => _environment == dev;
|
|
|
|
/// 프로덕션 환경 여부
|
|
static bool get isProduction => _environment == prod;
|
|
|
|
/// API 베이스 URL
|
|
static String get apiBaseUrl {
|
|
return dotenv.env['API_BASE_URL'] ?? 'http://localhost:8080/api/v1';
|
|
}
|
|
|
|
/// API 타임아웃 (밀리초)
|
|
static int get apiTimeout {
|
|
final timeoutStr = dotenv.env['API_TIMEOUT'] ?? '30000';
|
|
return int.tryParse(timeoutStr) ?? 30000;
|
|
}
|
|
|
|
/// 로깅 활성화 여부
|
|
static bool get enableLogging {
|
|
final loggingStr = dotenv.env['ENABLE_LOGGING'] ?? 'false';
|
|
return loggingStr.toLowerCase() == 'true';
|
|
}
|
|
|
|
/// 환경 초기화
|
|
static Future<void> initialize([String? environment]) async {
|
|
_environment = environment ??
|
|
const String.fromEnvironment('ENVIRONMENT', defaultValue: dev);
|
|
|
|
final envFile = _getEnvFile();
|
|
try {
|
|
await dotenv.load(fileName: envFile);
|
|
} catch (e) {
|
|
print('Failed to load env file $envFile: $e');
|
|
// .env 파일이 없어도 계속 진행
|
|
}
|
|
}
|
|
|
|
/// 환경별 파일 경로 반환
|
|
static String _getEnvFile() {
|
|
switch (_environment) {
|
|
case prod:
|
|
return '.env.production';
|
|
case dev:
|
|
default:
|
|
return '.env.development';
|
|
}
|
|
}
|
|
|
|
/// 환경 변수 가져오기
|
|
static String? get(String key) {
|
|
return dotenv.env[key];
|
|
}
|
|
|
|
/// 환경 변수 존재 여부 확인
|
|
static bool has(String key) {
|
|
return dotenv.env.containsKey(key);
|
|
}
|
|
} |