You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm doing a barrel export and notice when using only elements from 1 export files it doesn't give unnecessary_import at all.
For example if I have a.dart
classA {}
classA2 {}
b.dart
classB {}
c.dart
classC {}
alphabet.dart
export'a.dart';
export'b.dart';
export'c.dart';
and used it like so, the analyzer give feedback unnecessary_import for all a, b, c dart files
import'package:hmmm/src/alphabet/a.dart'; // unnecessary_importimport'package:hmmm/src/alphabet/b.dart'; // unnecessary_importimport'package:hmmm/src/alphabet/c.dart'; // unnecessary_importimport'package:hmmm/src/alphabet/alphabet.dart';
voidsomething() {
final a =A();
final a2 =A2();
final b =B();
final c =C();
}
but if only element used from a.dart, it doesn't give unnecessary_import to a, only unused_import for b and c.
import'package:hmmm/src/alphabet/a.dart';
import'package:hmmm/src/alphabet/b.dart'; // unused_importimport'package:hmmm/src/alphabet/c.dart'; // unused_importimport'package:hmmm/src/alphabet/alphabet.dart';
voidsomething() {
final a =A();
final a2 =A2();
// final b = B();// final c = C();
}
dart --version
Dart SDK version: 2.15.1 (stable) (Tue Dec 14 13:32:21 2021 +0100) on "windows_x64"
IDE
vscode
The text was updated successfully, but these errors were encountered:
In the second case you describe, alphabet.dart and a.dart provide the same set of "used" elements (A and A2). We consider these "redundant" imports, rather than "unnecessary."
We have not yet landed the check for redundant imports. The check is more complicated, because when two import directives provide the same set of used elements, we want to be careful about recommending which import directive to remove.
I'm doing a barrel export and notice when using only elements from 1 export files it doesn't give
unnecessary_import
at all.For example if I have
a.dart
b.dart
c.dart
alphabet.dart
and used it like so, the analyzer give feedback
unnecessary_import
for all a, b, c dart filesbut if only element used from
a.dart
, it doesn't giveunnecessary_import
to a, onlyunused_import
for b and c.dart --version
Dart SDK version: 2.15.1 (stable) (Tue Dec 14 13:32:21 2021 +0100) on "windows_x64"
IDE
vscode
The text was updated successfully, but these errors were encountered: