injectable
injectable copied to clipboard
'type != null || const Object() is! T': GetIt: The compiler could not infer the type. You have to provide a type and optional a name.
At the launch of my app, I get the following error :
_AssertionError ('package:get_it/get_it_impl.dart': Failed assertion: line 274 pos 7: 'type != null || const Object() is! T': GetIt: The compiler could not infer the type. You have to provide a type and optional a name. Did you accidentally do var sl=GetIt.instance();
instead of var sl=GetIt.instance;)
I can assure that I didn't do GetIt.instance(), rather I did GetIt.instance.
Here is how I configured getIt
:
final GetIt getIt = GetIt.instance;
@injectableInit
void configureInjection(String env) {
$initGetIt(getIt, environment: env);
}
And then :
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
configureInjection(Environment.prod);
runApp(MyApp());
}