injectable icon indicating copy to clipboard operation
injectable copied to clipboard

Dependency cannot be resolved if referenced by group import file

Open liri2006 opened this issue 3 years ago • 2 comments

Hi, today added injectable to the project for the first time and I have to say that this lib is pure gold!

In the meantime I've stumbled across the issue when trying to use injectable class which is referenced through the intermediary bulk export file.

For example there is a class:

@singleton
class Http {
}

which is exported through index.dart like:

export 'http.dart';

and then using it as a dependency for another class:

import 'package:app/core/services/index.dart';

@injectable
class UserRepository {
  final Http _http;

  UserRepository(this._http) : assert(_http != null);
}

During generation I'm getting error "[UserRepository] depends on unregistered type [Http]" and config file looks like this:

  gh.factory<UserRepository>(() => UserRepository(get()));
 
  // Eager singletons must be registered in the right order
  gh.singleton<WndHttp>(WndHttp());

If file is referenced directly everything is fine.

liri2006 avatar Aug 20 '20 22:08 liri2006

That issue made package unusable for me

ayalma avatar Feb 20 '22 18:02 ayalma

I'm also facing this issue :/

carlosfiori avatar Jun 23 '22 17:06 carlosfiori