Files
superport/lib/core/config/environment.dart
JiWoong Sul e7860ae028
Some checks failed
Flutter Test & Quality Check / Test on macos-latest (push) Has been cancelled
Flutter Test & Quality Check / Test on ubuntu-latest (push) Has been cancelled
Flutter Test & Quality Check / Build APK (push) Has been cancelled
feat: 소프트 딜리트 기능 전면 구현 완료
## 주요 변경사항
- Company, Equipment, License, Warehouse Location 모든 화면에 소프트 딜리트 구현
- 관리자 권한으로 삭제된 데이터 조회 가능 (includeInactive 파라미터)
- 데이터 무결성 보장을 위한 논리 삭제 시스템 완성

## 기능 개선
- 각 리스트 컨트롤러에 toggleIncludeInactive() 메서드 추가
- UI에 "비활성 포함" 체크박스 추가 (관리자 전용)
- API 데이터소스에 includeInactive 파라미터 지원

## 문서 정리
- 불필요한 문서 파일 제거 및 재구성
- CLAUDE.md 프로젝트 상태 업데이트 (진행률 80%)
- 테스트 결과 문서화 (test20250812v01.md)

## UI 컴포넌트
- Equipment 화면 위젯 모듈화 (custom_dropdown_field, equipment_basic_info_section)
- 폼 유효성 검증 강화

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-12 20:02:54 +09:00

111 lines
3.3 KiB
Dart

import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter/foundation.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 {
try {
return dotenv.env['API_BASE_URL'] ?? 'http://43.201.34.104:8080/api/v1';
} catch (e) {
// dotenv가 초기화되지 않은 경우 기본값 반환
return 'http://43.201.34.104:8080/api/v1';
}
}
/// API 타임아웃 (밀리초)
static int get apiTimeout {
try {
final timeoutStr = dotenv.env['API_TIMEOUT'] ?? '60000';
return int.tryParse(timeoutStr) ?? 60000;
} catch (e) {
return 60000;
}
}
/// 로깅 활성화 여부
static bool get enableLogging {
try {
final loggingStr = dotenv.env['ENABLE_LOGGING'] ?? 'false';
return loggingStr.toLowerCase() == 'true';
} catch (e) {
return true; // 테스트 환경에서는 기본적으로 로깅 활성화
}
}
/// API 사용 여부 (Mock 서비스 제거로 항상 true)
static bool get useApi => true;
/// 환경 초기화
static Future<void> initialize([String? environment]) async {
_environment = environment ??
const String.fromEnvironment('ENVIRONMENT', defaultValue: dev);
final envFile = _getEnvFile();
if (kDebugMode) {
debugPrint('[Environment] 환경 초기화 중...');
debugPrint('[Environment] 현재 환경: $_environment');
debugPrint('[Environment] 환경 파일: $envFile');
}
try {
await dotenv.load(fileName: envFile);
if (kDebugMode) {
debugPrint('[Environment] 환경 파일 로드 성공');
// 모든 환경 변수 출력
debugPrint('[Environment] 로드된 환경 변수:');
dotenv.env.forEach((key, value) {
debugPrint('[Environment] $key: $value');
});
debugPrint('[Environment] --- 설정 값 확인 ---');
debugPrint('[Environment] API Base URL: ${dotenv.env['API_BASE_URL'] ?? '설정되지 않음'}');
debugPrint('[Environment] API Timeout: ${dotenv.env['API_TIMEOUT'] ?? '설정되지 않음'}');
debugPrint('[Environment] 로깅 활성화: ${dotenv.env['ENABLE_LOGGING'] ?? '설정되지 않음'}');
}
} catch (e) {
if (kDebugMode) {
debugPrint('[Environment] ⚠️ 환경 파일 로드 실패: $envFile');
debugPrint('[Environment] 에러 상세: $e');
debugPrint('[Environment] 기본값을 사용합니다.');
}
// .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);
}
}