refactor: 코드베이스 정리 및 에러 처리 개선

- API 클라이언트 및 인증 인터셉터 에러 처리 강화
- 의존성 주입 실패 시에도 앱 실행 가능하도록 개선
- 사용하지 않는 레거시 UI 컴포넌트 및 화면 제거
- pubspec.yaml 의존성 업데이트

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
JiWoong Sul
2025-07-25 18:15:21 +09:00
parent 71b7b7f40b
commit ad2c699ff7
39 changed files with 193 additions and 4134 deletions

View File

@@ -20,8 +20,13 @@ void main() async {
// Flutter 바인딩 초기화
WidgetsFlutterBinding.ensureInitialized();
// 의존성 주입 설정
await di.setupDependencies();
try {
// 의존성 주입 설정
await di.setupDependencies();
} catch (e) {
print('Failed to setup dependencies: $e');
// 에러가 발생해도 앱은 실행되도록 함
}
// MockDataService는 싱글톤으로 자동 초기화됨
runApp(const SuperportApp());
@@ -32,7 +37,12 @@ class SuperportApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
final authService = GetIt.instance<AuthService>();
AuthService? authService;
try {
authService = GetIt.instance<AuthService>();
} catch (e) {
print('Failed to get AuthService: $e');
}
return MaterialApp(
title: 'supERPort',
@@ -44,26 +54,35 @@ class SuperportApp extends StatelessWidget {
],
supportedLocales: const [Locale('ko', 'KR'), Locale('en', 'US')],
locale: const Locale('ko', 'KR'),
home: FutureBuilder<bool>(
future: authService.isLoggedIn(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Scaffold(
body: Center(
child: CircularProgressIndicator(),
),
);
}
if (snapshot.hasData && snapshot.data!) {
// 토큰이 유효하면 홈 화면으로
return AppLayoutRedesign(initialRoute: Routes.home);
} else {
// 토큰이 없거나 유효하지 않으면 로그인 화면으로
return const LoginScreen();
}
},
),
home: authService == null
? const LoginScreen() // AuthService가 없으면 바로 로그인 화면
: FutureBuilder<bool>(
future: authService.isLoggedIn(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Scaffold(
body: Center(
child: CircularProgressIndicator(),
),
);
}
// 에러 처리 추가
if (snapshot.hasError) {
print('Auth check error: ${snapshot.error}');
// 에러가 발생해도 로그인 화면으로 이동
return const LoginScreen();
}
if (snapshot.hasData && snapshot.data!) {
// 토큰이 유효하면 홈 화면으로
return AppLayoutRedesign(initialRoute: Routes.home);
} else {
// 토큰이 없거나 유효하지 않으면 로그인 화면으로
return const LoginScreen();
}
},
),
onGenerateRoute: (settings) {
// 로그인 라우트 처리
if (settings.name == '/login') {