ntminhdn / Flutter-Bloc-CleanArchitecture

457 stars 200 forks source link

how to use RouteGuards with AppRouter #7

Closed ALAZZURRI closed 1 year ago

ALAZZURRI commented 1 year ago

i try use RouteGuards with AppRouter but get error " _AssertionError ('package:get_it/get_it_impl.dart': Failed assertion: line 372 pos 7: 'instanceFactory != null': Object/factory with type RouteGuards 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?))"

image

ntminhdn commented 1 year ago

@ALAZZURRI This is a bug. Because I arrange modules' configs in an incorrect order. I fixed it in this PR https://github.com/ntminhdn/Flutter-Bloc-CleanArchitecture/pull/8/files#diff-3dbe1bd3a89c130724b755031d3bc733252257b3329bbd3579a1ce585992f5a4R16 You need to place await di.configureInjection() above GetIt.instance.registerSingleton<AppRouter> too.