New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Injectable: Created file resolves imports incorrectly #12
Comments
This also happens with Firebase. It imports |
Hey @ResoDev @PDDStudio, |
@PDDStudio You mean two import statements are generated? |
@Milad-Akarie yes, just tested it again. import 'package:firebase_auth/src/firebase_auth.dart'; which is actually an error: Here's the module: @registerModule
abstract class FirebaseInjectableModule {
@singleton
GoogleSignIn get googleSignIn => GoogleSignIn();
@singleton
FirebaseAuth get firebaseAuth => FirebaseAuth.instance;
} Once this gets resolved, this library will be 🔥🔥🔥💯 |
@ResoDev I'm actually working on a better approach to handling custom initializers that will solve all the import issues and more, hopefully it will be done by this weekend so stay tuned. |
@Milad-Akarie Thank you. I hope we're going to arrive at a stable-ish version because I'd love to use this package in a tutorial series. A bit off-topic here, but get_it 4.0.0 shouldn't disrupt the API of this lib, right? Maybe just the implementation. |
@ResoDev I don't think it will, I've already tried it with get_it v4 and everything worked just fine, I'll add support to v4 as soon as it's released or maybe even before. |
@PDDStudio @ResoDev This should be fixed in v0.2.3 check it out! |
Sorry for the late reply, I totally lost track of this issue. We've updated to |
@Milad-Akarie // GENERATED CODE - DO NOT MODIFY BY HAND // ************************************************************************** void $initGetIt(GetIt g, {String environment}) { } class _$InjectableModules extends InjectableModules {} |
@sedobrengocce it's importing from the src not the library? |
@Milad-Akarie sure! import 'package:injectable/injectable.dart';
import 'package:http/http.dart' as http;
import 'package:shared_preferences/shared_preferences.dart';
@module
abstract class InjectableModules {
@lazySingleton
http.Client get httpClient => http.Client();
@lazySingleton
@preResolve
Future<SharedPreferences> get sharedPreferences async => await SharedPreferences.getInstance();
} |
Hello,
We've started using injectable in our project.
I've realized that the generated file has some problems with wrong/duplicated imports.
For example, I've my
dio
instance registered viaregisterModule
&lazySingleton
.After generating the
iconfig.dart
file I can see that there are problems with resolving the correct import ofdio
:I don't know if this issue has been reported yet, but I couldn't find anything similar to this.
For now I'm ending up removing the duplicated (& wrong) import by hand.
The text was updated successfully, but these errors were encountered: