Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: [공통] get_it을 사용한 의존성 주입 환경 구축 #31 #32

Merged
merged 1 commit into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/app/di/app_binding.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
final class AppBinder {
AppBinder._();

/// 'Splash' 단계에서 우선적으로 Binding 해야되는 모듈들은
/// 아래 메소드에서 처리합
static void _initTopPriority() {}

static void init() {
_initTopPriority();

for (final di in []) {
di.init();
}
}
}
11 changes: 11 additions & 0 deletions lib/app/di/feature_di_interface.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
abstract base class FeatureDependencyInjection {
void init() {
dataSources();
repositories();
useCases();
}

void dataSources();
void repositories();
void useCases();
}
17 changes: 17 additions & 0 deletions lib/app/di/locator.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import 'package:get_it/get_it.dart';

final GetIt locator = GetIt.I;

// 안전하게 등록된 인스턴스를 해제하는 메소드
void safeUnregister<T extends Object>() {
if (locator.isRegistered<T>()) {
locator.unregister<T>();
}
}

// 안전하게 Factory 인스턴스를 등록하는 메소드
void safeRegisterFactory<T extends Object>(FactoryFunc<T> factoryFunc) {
if (!locator.isRegistered<T>()) {
locator.registerFactory<T>(factoryFunc);
}
}
38 changes: 21 additions & 17 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,55 +7,59 @@ environment:
sdk: ">=3.0.0 <4.0.0"

dependencies:
bloc: ^8.1.2
change_app_package_name: ^1.1.0
cupertino_icons: ^1.0.2
flutter:
sdk: flutter

# Firebase
firebase_core: ^2.15.0
firebase_auth: ^4.7.2
sign_in_with_apple: ^5.0.0
google_sign_in: ^6.1.4
kakao_flutter_sdk_auth: ^1.5.0
kakao_flutter_sdk_user: ^1.4.1
go_router: ^10.0.0
intl: ^0.18.1
dio: ^5.2.1+1
freezed_annotation: ^2.4.1
google_maps_flutter: ^2.4.0
retrofit: ^4.0.3
infinite_scroll_pagination: ^4.0.0

# UI
cupertino_will_pop_scope: ^1.2.1 #pop scope (스와이프 백 제스쳐 지원)
fluttertoast: ^8.2.2
flutter_svg: ^2.0.7
flutter_easyloading: ^3.0.5
cupertino_icons: ^1.0.2

# 상태관리
flutter_riverpod: ^2.3.6
riverpod_annotation: ^2.1.1

# 네트워크
retrofit: ^4.0.3
dio: ^5.2.1+1

# DI
get_it: ^7.2.0

# 라우팅
go_router: ^10.0.0


# Utils
intl: ^0.18.1
freezed_annotation: ^2.4.1

# 앱 정보
change_app_package_name: ^1.1.0

dev_dependencies:
flutter_test:
sdk: flutter
mocktail: ^0.3.0
# a tool for running code generators
build_runner: ^2.4.6
# the code generator
riverpod_generator: ^2.2.3
# riverpod_lint makes it easier to work with Riverpod
riverpod_lint: ^1.3.2
# import custom_lint too as riverpod_lint depends on it
custom_lint: ^0.4.0

flutter_flavorizr: ^2.2.1

flutter_lints: ^2.0.0
freezed: ^2.4.1
json_serializable: ^6.7.1
retrofit_generator: ^7.0.2 # 네트워크 API Generator

flutter:
assets:
Expand Down Expand Up @@ -89,4 +93,4 @@ flutter:
- asset: assets/fonts/Pretendard-ExtraBold.otf
weight: 800
- asset: assets/fonts/Pretendard-Black.otf
weight: 900
weight: 900