injectable
injectable copied to clipboard
Different return type
Hello 👋
in @module I have custom Dio client which is returns Future<Dio>,
@preResolve
Future<Dio> get dio => CustomDioClient.createDio();
and ApiClient which needs to have Dio instance like
ApiClient get apiClient => ApiClient(injector<Dio>());
in .config it's generated like this:
gh.factoryAsync<_i5.CustomDioClient>(() => _i5.CustomDioClient.createDio());
But I get error: Error: A value of type 'Future<Dio>' can't be returned from a function with return type 'Future<CustomDioClient>. I am not sure what I am doing wrong. Thanks for any advise 🙏
@stepanzalis not sure what's going on here but why are you injecting Dio manually here?
ApiClient get apiClient => ApiClient(injector<Dio>());
that might be the cause.
ApiClient
above is abstract class which will is generated and needs Dio as dependency. I also need to create my custom Dio client which has all interceptors etc. (CustomDioClient
) which returns Future<Dio>
. When I inject it to ApiClient
, error says that I pass instance of CustomDioClient and not instance of Dio.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions