flutter error get_it

 [ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: Bad state: GetIt: Object/factory with type loginService is not registered inside GetIt. 

(Did you accidentally do GetIt sl=GetIt.instance(); instead of GetIt sl=GetIt.instance;

Did you forget to register it?)

해결 방안

await setupLocator(); 선언 해주어야 한다.

void main() async {

/*  WidgetsFlutterBinding.ensureInitialized() is required in Flutter v1.9.4+ 
 *  before using any plugins if the code is executed before runApp. 
 */
  WidgetsFlutterBinding.ensureInitialized();


// Configure injecction
   await setupLocator();

   runApp(MyApp());
}

댓글

이 블로그의 인기 게시물

자바 string 비교 할때 equlas 를 사용하자

jqgrid 에서 export execl 붙이기

flutter webview scroll 안되는 경우 gestureRecognizers: gestureRecognizers, 추가 해서 되었다