Bad state 에러
안녕하세요.
아래와 같은 오류가 나서 해결을 하려고 했습니다.
제공해주신 완성 본 코드와 비교하니 정확하게 일치했구요.
E/flutter (22734): [ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: Bad state: GetIt: Object/factory with type StoreRepository is not registered inside GetIt. E/flutter (22734): (Did you accidentally do GetIt sl=GetIt.instance(); instead of GetIt sl=GetIt.instance;
이해가 안되어서 di_setup_config.dart파일을 보는데
const String dev = 'dev';
const String prod = 'prod';
extension GetItInjectableX on i174.GetIt {
// initializes the registration of main-scope dependencies inside of GetIt
i174.GetIt init({
String? environment,
i526.EnvironmentFilter? environmentFilter,
}) {
final gh = i526.GetItHelper(
this,
environment,
environmentFilter,
);
gh.singleton<_i149.LocationPermissionHandler>(
() => i399.MockLocationPermissionHandler(),
registerFor: {dev},
);
gh.singleton<_i872.StoreRepository>(
() => i399.MockStoreRepositoryImpl(),
registerFor: {dev},
);
gh.singleton<_i920.LocationRepository>(
() => i399.MockLocationRepositoryImpl(),
registerFor: {dev},
);
gh.singleton<_i716.GetNearByStoresUseCase>(
() => i716.GetNearByStoresUseCase(
storeRepository: gh<i872.StoreRepository>(),
locationRepository: gh<_i920.LocationRepository>(),
locationPermissionHandler: gh<_i149.LocationPermissionHandler>(),
));
gh.singleton<_i920.LocationRepository>(
() => i359.LocationRepositoryImpl(),
registerFor: {prod},
);
gh.singleton<_i872.StoreRepository>(
() => i303.StoreRepositoryImpl(),
registerFor: {prod},
);
gh.singleton<_i149.LocationPermissionHandler>(
() => i148.LocationPermissionHandlerImpl(),
registerFor: {prod},
);
gh.factory<_i912.MainViewModel>(
() => i912.MainViewModel(gh<i716.GetNearByStoresUseCase>()));
return this;
}
}
GetNearByStoresUseCase 코드가 prod버전의 코드들 보다 상위에 배치되어서 발생했습니다.
di_setup_config.dart파일을 자동으로 생성되는 파일인데 매번 dart run build_runner build 할 때 마다 일일이 수동으로 수정을 해줘야 할까요?
flutter pub run build_runner build --delete-conflicting-outputs
를 해도 동일합니다.
답변 1
vscode or 안드로이드 디바이스가 아닌 웹으로 실행했을때..
0
25
2
성능 분석 툴 공유
1
47
2
146 자료는 학습완료가 체크가 안돼요
0
34
1
'플러터 개발환경 세팅하기' 링크 클릭시, 악성 스크립트 설치 유도 페이지로 이동하니 조심하시길 바랍니다.
0
65
2
[강의 문의] '앱 출시하기' 강의 추가 일정 관련하여 문의드립니다.
0
42
1
안드로이드 기기 실행 오류
0
64
2
수강연장 가능할까요...
0
60
2
플러터 세팅 후 새폴더 생성건
0
56
2
강의에서 사용된 안드로이드 스튜디오 버전을 알고싶어요.
0
63
2
강의 자료는 어디있나요?
0
41
1
이미지 업로드해도 프로필에 x만 떠요
0
67
3
cursor ai가 업데이트 되서 ui가 바뀌었는데 반영은 안될까요?
0
80
2
마스크 json url이 안보여서 공유합니다
0
94
1
DI 에 대해 문의 좀 드립니다.
0
139
2
여러 화면 di강의는 언제 나올 예정인가요?
0
203
1
Riverpod 프로바이더에 의존성 주입
0
970
1
remote data source impl
0
293
1
go router 의존성
0
308
1
객체가 아닌 일반 변수의 get it
0
298
1
뷰 모델 분리하기
0
361
1
네트워크 통신 에러 처리
0
350
1
데이터 추상화 문제
0
351
2
로그인(auth)관련 데이터 흐름
0
276
1
소스코드 공유
0
451
1





