-
Notifications
You must be signed in to change notification settings - Fork 324
Auto import for list firstWhereOrNull method throws a warning. #3900
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
Comments
@safield can you confirm the version of the SDK you're using? This looks like dart-lang/sdk#47842 which seems to have been fixed, although I'm not certain if it's in the SDK you're using yet. |
I did update version a day ago and now there is no incorrect recommendation. But there is also no correct recommended code action either. |
@safield can you confirm your SDK version and perhaps provide a small repro? In a simple test, it does seem to show up for me: |
Flutter 2.10.4 • channel stable • https://github.com/flutter/flutter.git Running on Ubuntu 21.10 with flutter install through the official snap package. |
Is If so, are you able to share a small sample project this definitely occurs for you in that I can test with? |
It is not added to my pubspec.yaml. I assumed it was a package that was part of the default SDK packages. I do not have it in my pubspec.yaml, but adding the following line to a dart file compiles and runs without error or warning...
|
Ah, that will be the issue. The reason it works at runtime is that the package is being referenced by some other dependency, so the runtime is able to resolve it and find the source. However the analysis server (which provides the language features) will not suggest imports for packages you have not explicitly listed in If you depend on a package, it should always be listed explicitly in your If you want to get a warning when you depend on something not in your pubspec (such as if you Hope this helps! |
When using the list extension method firstWhereOrNull, the dart-code extension only suggests the import statement..
import 'package:collection/src/iterable_extensions.dart';
When selecting this option, the extension gives the warning for the resulting import line...
Don't import implementation files from another package.
The correct import
import 'package:collection/collection.dart';
is not suggested.The text was updated successfully, but these errors were encountered: