injectable icon indicating copy to clipboard operation
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.

Open jnknewaj opened this issue 4 years ago • 0 comments

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());
}

jnknewaj avatar Dec 03 '20 13:12 jnknewaj